I am a newbie to network programming. I been trying my luck with winsock and am stuck with no idea what to do.
Here is a snippet of my code:
//Bind it to a TCP/IP port
SOCKADDR_IN SockAddr;
SockAddr.sin_port=24; /*Port to be used*/
SockAddr.sin_family=AF_INET; /*Connection Type: TCP/IP*/
/*Listen on IP address: 127.0.0.1*/
SockAddr.sin_addr.S_un.S_un_b.s_b1 = 127;
SockAddr.sin_addr.S_un.S_un_b.s_b2 = 0;
SockAddr.sin_addr.S_un.S_un_b.s_b3 = 0;
SockAddr.sin_addr.S_un.S_un_b.s_b1 = 1;
if(bind(socketDefinition,(SOCKADDR*)(&SockAddr),sizeof(SockAddr))==SOCKET_ERROR)
printf("Attempt to bind failed.");
The code is compiling properly but output is: "Attempt to bind failed."
Any suggestions?
Thanks.