Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

Winsock

This topic is 4289 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I coded a server program and a client program. I open the server program, then the client program. The server then finds the client and everything works. For now this is only working on one computer. I gave this client program to one of my friends and it didn't connect. I assume its an IP adress problem. The adress in the client program is from running ipconfig. Any help?

Share this post


Link to post
Share on other sites
Advertisement
If your pc is connected to a router the ip shown in ipconfig is not the right to use. In this case you can get your extern ip address for example from this address: http://whatismyipaddress.com/

It's also possible that your firewall doesn't allow this connection.

Share this post


Link to post
Share on other sites
Yea my friend noted that, about the router ip. I used the router ip and it still doesnt work. And the firewall asks and I told it to allow the connection. The only error codes I'm getting on the client side are "connection timeout". My server never finds the client.

Client
------
sock.sin_family = AF_INET;
sock.sin_addr.s_addr = inet_addr("67.183.129.218");
sock.sin_port = htons(5001);

sendSock = socket(AF_INET, SOCK_STREAM, 0);
connect(sendSock, (SOCKADDR*)&sock, sizeof(sock));



Server
------
sock.sin_family = AF_INET;
sock.sin_addr.s_addr = INADDR_ANY;
sock.sin_port = htons(5001);

sendSock = socket(AF_INET, SOCK_STREAM, 0);
bind(sendSock, (SOCKADDR*)&sock, sizeof(sock) );
listen(sendSock, SOMAXCONN);

while(Client == INVALID_SOCKET)
{
Client = accept(sendSock, NULL, NULL);
}

Share this post


Link to post
Share on other sites
If you have a router, you need to tell it to forward that port to your computer. I don't know the details of how to do that (it will be part of your router config and may well be router-dependent) – if anyone does, though, it's this forum!

Share this post


Link to post
Share on other sites
Hell yea. It works. Does anyone know if I can do port forwarding in winsock. I ask because, say I have a person run a game and broadcasts to see if another game started. If he doesnt find a server, then I need to make him the server.

Share this post


Link to post
Share on other sites
The Forum FAQ talks about NAT punch-through, which is the only way you can host a game inside a firewall without explicit port forwarding. Note that it requires a collaborating matchmaker host that doesn't have a firewall.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!