Jump to content
  • Advertisement
Sign in to follow this  
Shashwat Rohilla

Socket Programming

This topic is 2770 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 created a game in XNA C# in VS 2008.
The game has two application files. One is the server and the other is the game which refreshes a list of servers and connects to the game running.
In the game, we can see the list of servers running.

When I created the game, I was connected to the network and thus I was able to set my local IP as 192.168.1.2.
Everything was running fine!

But when I transferred the game to my laptop which is not connected to any network, I was unable to change my IP.
Thus, the server program raised an exception in starting the server.

I tried running a local server of Counter Strike, it was creating the server on loopback address when not connected to any network.

However, I have used

hostentry.addressList[0].address

It says it is obsolete. However, it was running fine in my desktop pc but now, since the laptop is not connected to any network, its not working.
But When I hard-code the address as loopback address, then it runs perfectly.

My Question is:
Before starting the server, do I have to check whether the machine is connected to some network or not?

Please help!

Share this post


Link to post
Share on other sites
Advertisement
I think if you have no network and therefore no gateway, the machine can't have an IP identity. Or if the loopback works, just set that as the address when you get the socket error (indicating no network). Are you making a game that runs in client/server mode even in single player?

Share this post


Link to post
Share on other sites
Are you making a game that runs in client/server mode even in single player?


Yes, I've created that game. It was working fine in my PC because it was connected to the internet.
But it is not working in my laptop which is not connected to any network.

[quote name='avocados']if the loopback works, just set that as the address when you get the socket error (indicating no network)[/quote]

I have also thought to do so.
Thank you very much.

But I have one doubt.
To search the games, it broadcast the message to broadcast address 192.168.1.255. Shall I send it so 192.168.2.255 or 192.168.3.255 ..... (to which network)
Will it reveal the loopback address?
Will my game be able to search the loopback server through broadcast address?

Share this post


Link to post
Share on other sites
Send to 255.255.255.255. There is no guarantee that you are on a 192.168.X.X network (10.X.X.X is another private address space that is often used). Servers listening on any connected interface (including the loopback) should receive such a message.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!