Jump to content
  • Advertisement
Sign in to follow this  
sheep19

[SDLNet] Server does not receive incoming connection from client

This topic is 1334 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 am making a simple Client-Server application.

For now, I am trying to create a server and a client, and make the client connect to the server. When this is done, the server should print a message.

 

-- Server --

http://pastebin.com/xFT3Eau4

 

-- Client --

http://pastebin.com/24Trvf3E

 

First I run the server.

Then I run the client, it prints 0.0.0.0 but the server does not seem to receive the connection request by the client. No errors are printed however (really strange...)

 

If I try to change the IP that the client connects to to the local IP of the pc the server is running (192.168.x.y) or to localhost I get "Couldn't connect to remote host" from the client... But why? Shouldn't these work in the same way as 0.0.0.0?

 

What troubles me is that with 0.0.0.0 the client seems to connect to the server (no errors by the client) but the server never receives the request. Maybe it's blocked by a firewall or am I doing something really wrong?

Share this post


Link to post
Share on other sites
Advertisement
0.0.0.0 means "all local interfaces" when bindint a socket to local network interfaces, but it is not a valid IP address for creating/connecting connections. Edited by hplus0603

Share this post


Link to post
Share on other sites
A good tip for debugging networked programs is to substitute programs known to work.

For example, use the existing program "telnet" or "netcat" to simulate a TCP client (at least one is likely to be already installed on your system).

You can use many programs as a server for testing basic connectivity, you can attempt to connect to www.google.com on port 80, I believe netcat has a server mode.

With these tools, you can gain confidence as to what is expected behaviour and what could be a bug in your program.

Share this post


Link to post
Share on other sites

I found the problem. On Server I should have initialized the IPaddress structure using this function:

SDLNet_ResolveHost(&ip, nullptr, 12000)

 

instead of setting the fields manually.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!