Jump to content
  • Advertisement
Sign in to follow this  
RoundPotato

sucking potata

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

Advertisement

I have been searching for some information as well.

One thing you should definitely do is follow the instructions on the MSDN website on Winsock: LINK

 

Also, take a look at Beej's Networking Guide (or something similar). He gives a very nice explanation of every step in the Winsock setup. (Information on every function and what not).

 

I also made a blog post about networking if you wish to read it: BLOG

 

Regards,

Frostraver

Share this post


Link to post
Share on other sites
Both Java and C# just put an abstraction layer over sockets, C# of course only cares about winsock being .net normally, while Java just abstracts over the different socket libraries depending on platform. Essentially you could do the same thing yourself in C++, or use a library that does it already.

The thing is, unlike a lot of other stuff sockets are very similar in both unix sockets and winsock, winsock is essentially just a windows implementation of the same sockets so the usage of both can be covered pretty well in tutorials. Unlike something like windowing where win32/winapi is rather different from xlib.

Share this post


Link to post
Share on other sites

Winsock isn't terribly different from BSD sockets. You have to initialize it with and include a header, and close() becomes CloseSocket(), but apart from that they're almost identical.

Share this post


Link to post
Share on other sites
Since C++ is on a much lower level Socket programming makes use of sockets implemented for each Operating System

Although C++ makes it easier than Java or .NET to work directly with low level C code, generally there is no reason that you should.

 

However as Khatharr mentioned, the sockets API on most platforms is very similar (Mainly because Winsock was designed based on BSD sockets a long time ago).

This combined with the fact that using the sockets API directly isn't that difficult (i.e not too much boilerplate code required to get quick results) so I probably suggest wrapping your own socket library. I could give you a link to loads of premade socket libraries but personally I dislike using other peoples wrappers for this kind of thing.

 

Below is a list of simple examples. I use these as a basis for my own netcode.

 

Winsock

Server - http://msdn.microsoft.com/en-us/library/windows/desktop/ms737593%28v=vs.85%29.aspx

Client - http://msdn.microsoft.com/en-us/library/windows/desktop/ms737591%28v=vs.85%29.aspx

 

POSIX / BSD / UNIX Sockets

Server - http://www.linuxhowtos.org/data/6/server.c

Client - http://www.linuxhowtos.org/data/6/client.c

 

Of course there is also Boost.Asio if you want to use a pseudo standard library (Akin to .NET and Java sockets).

 

For UDP, have a look at the simple examples here - en.wikipedia.org/wiki/Berkeley_sockets

Edited by Karsten_

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!