Bind Error
-
Hi,:confused: I am in very New to VC, and I have written a code which will connect to another machine and return either a -1 or non negative value. I am getting a "-1" for bind function. Please can some one help me out with it.. ============================================================== #include #include #include #include WSADATA wsData; SOCKADDR_IN saServer; SOCKET s; void main() { WORD wVersionRequested = MAKEWORD(1,1); int nRet,sd,d; // // Initialize WinSock // nRet = WSAStartup(wVersionRequested, &wsData); printf("WSASTARTUP nret = %d\n",nRet); sd = socket(AF_INET, SOCK_STREAM, 0); printf("SOCKET = %ld\n",s); saServer.sin_family=AF_INET; saServer.sin_addr.s_addr = inet_addr("192.168.0.4"); saServer.sin_port=htons(80); d = bind(s,(struct sockaddr*)&saServer,sizeof(saServer)); printf("BIND = %ld\n",d); getchar(); } =============================================================
-
Hi,:confused: I am in very New to VC, and I have written a code which will connect to another machine and return either a -1 or non negative value. I am getting a "-1" for bind function. Please can some one help me out with it.. ============================================================== #include #include #include #include WSADATA wsData; SOCKADDR_IN saServer; SOCKET s; void main() { WORD wVersionRequested = MAKEWORD(1,1); int nRet,sd,d; // // Initialize WinSock // nRet = WSAStartup(wVersionRequested, &wsData); printf("WSASTARTUP nret = %d\n",nRet); sd = socket(AF_INET, SOCK_STREAM, 0); printf("SOCKET = %ld\n",s); saServer.sin_family=AF_INET; saServer.sin_addr.s_addr = inet_addr("192.168.0.4"); saServer.sin_port=htons(80); d = bind(s,(struct sockaddr*)&saServer,sizeof(saServer)); printf("BIND = %ld\n",d); getchar(); } =============================================================