Socket Programming problem
serverSockAddrPtr = (struct sockaddr*) &serverINETAddress;
serverLen = sizeof (serverINETAddress);
bzero ((char *)&serverINETAddress, sizeof (serverINETAddress));
inetAddress = nameToAddr ("192.168.0.124");
serverINETAddress.sin_family = AF_INET;
serverINETAddress.sin_addr.s_addr = inetAddress;
serverINETAddress.sin_port = htons(HTTP_PORT);
// create unnamed socket
clientfd = socket (AF_INET, SOCK_STREAM, DEFAULT_PROTOCOL);
// connect to host
do {
result = connect (clientfd, serverSockAddrPtr, sizeof (serverSockAddrPtr));
} while (result == -1);
//////////// I was stuck here, result always -1, the word 'connect' is in blue color.
Thanks
Jack
|