WinSOCK bind function.
-
I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks
-
I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks
-
Well, thats not an option, since I'm using it on a LAN.
-
I'm trying to create a server which accepts client connections. .... Address.sin_family = AF_INET; Address.sin_port = htons(1212); Address.sin_addr.s_addr = htonl(INADDR_ANY); IntReturn = bind(Listen, (struct sockaddr *) &Address, sizeof(Address)); IntReturn = listen(Listen, 10); IntReturn = sizeof(RemoteAddress); Client[Computer].ClientSocket=accept(Listen, (struct sockaddr *) &RemoteAddress, &IntReturn); ... Clients from any! ip can connect to my server on port 1212.. My server should not accept connections from any ip, so how do I get my server to only accept connections from example 10.0.0.105 ? I thought about changing this line Address.sin_addr.s_addr = htonl(INADDR_ANY); to Address.sin_addr.s_addr = inet_addr("10.0.0.105"); but this does not work, am I doing something wrong? Thanks
Get IP from the connected client. Check if the IP is an accepted IP and if it's an accepted/allowed IP then start sending datta etc. if not, just disconnect the socket. Rickard Andersson Here is my card, contact me later! UIN: 50302279 Sonork: 37318 Interests: C++, ADO, SQL, Winsock, 0s and 1s