#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
CFSocketRef socket;
socket = CFSocketCreate(kCFAllocatorDefault,PF_INET,SOCK_STREAM,IPPROTO_TCP,0,NULL,NULL);
CFDataRef address, data;
struct sockaddr_in sin;
char message[] = "Hello Socket”;
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_port = htons(7258); //port
sin.sin_addr.s_addr = inet_addr("ip address");
address = CFDataCreate(NULL,(unsigned char*)&sin,sizeof(sin));
data = CFDataCreate(NULL,(unsigned char*)message,strlen(message));
CFSocketConnectToAddress(socket,address,0);
CFSocketSendData(socket,NULL,data,strlen(message));
CFRelease(address);
CFRelease(data);
CFRelease(socket);