client/server communication using CFSocket
client/server communication using CFSocket
- Subject: client/server communication using CFSocket
- From: "Rola Alame" <email@hidden>
- Date: Thu, 19 Jan 2006 12:24:03 +0000
Hello.
I'm writing two applications: one is a client and the other is a server for
them to communicate over the network using TCP/IP. i'm using high level
CFSocket function. The client is working fine. however, at the server, i'm
successfully creating the socket (with CFSocketCreate), but when i use
"CFSocketSetAddress" to bind a port to that socket, it's returning
kCFSocketError. and i can't figure out why. Here's the code for the server:
/////////////////////Server.c//////////////////////////
CFSocketRef servere = CFSocketCreate (NULL, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketConnectCallBack, MyCallBack, NULL);
if (server != NULL)
{
struct sockaddr_in serverAddr;
inet_aton ("192.168.1.11", &serverAddr.sin_addr);
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(2222);
serverAddr.sin_len = sizeof(serverAddr);
CFDataRef address = CFDataCreate (NULL, (UInt8*)&serverAddr,
sizeof (serverAddr));
if (address != NULL)
{
CFSocketError err = CFSocketSetAddress (server,
address);
if (err == kCFSocketError)
printf("error binding socket to
address\n";
}
}
when irun this code i always get the error message printed on the terminal.
Can anyone tell me what the problem could be and how to solve it?
Thanks.
Rola
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden