• Advertisement
Sign in to follow this  

Correctly establishing a server/client connection

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

Ive started to develop a multiplayer game, its going well, only just started though. I have one problem that I cant exactly get my head around though.

When a client connects to the game server several messages are sent back and fouth between the client and server in order to establish a connection (like a sequence of verify bytes, version information, login details).

Say if though, the versions between the client/server are different and the error of "Different client/server version." displays on the game client. How would I cancel/close the sockets which I have created in a correct manner. Right now I am just closing the socket (.net's TcpClient) on both the server and the client. But the thing is once the TcpClient is closed on one end it also closes automatically on the other end (due to the transmission control protocol id issume, or winsock).

Question: How would I close these sockets correctly on both ends?

I hope you understand what I am saying,

All replies are appriciated.
Thanks,
Xanather. Edited by Xanather

Share this post


Link to post
Share on other sites
Advertisement
Look up the shutdown() function.

Note that the socket itself doesn't get "closed" on the other end, just made an error to write to it. You still need to close()/closesocket() the socket handle to reclaim the kernel file descriptor/handle.

Share this post


Link to post
Share on other sites
Look up the shutdown() function.[/quote]
Ok, will do.

What do you mean by it doesnt get closed if the socket had a error to writing/reading? With .net's TcpClient the .Connected property always returns true until a read/write failes (even once) so thats strange.

Xanather.

Share this post


Link to post
Share on other sites
Ok, the way Ive set it up now is probably correct then, thanks smile.png Just got confused, read up on the Close() method and it does indeed release all managed/unmanaged resources.
The Close method marks the instance as disposed and requests that the associated Socket close the TCP connection[/quote] Edited by Xanather

Share this post


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

  • Advertisement