Sign in to follow this  

Winsock

This topic is 4074 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
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

This topic is 4074 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this