Handmade Hero»Forums»Code
Pete
22 posts
Network programming Win32
Edited by Pete on Reason: grammar
I have been looking for some good material for windows network programming. I know Casey will not be implementing multiplayer functionality so i wanted to try and figure it out by myself.

My question is if WinSock is the only alternative in C for Windows? So if handmade_hero would have network functionality would that be what we would have to use?
Livet Ersomen Strøm
163 posts
Network programming Win32
I don't know about C "alternatives". But the winsock library in windows, is not hard to get your head around. At least, considering the time you will spend to make your networkcode efficient, the time spent to connect a server to a client will not even count.
Matt Campbell
4 posts
Network programming Win32
If you're going down the socket route with Winsock I'd highly recommend Beej's Guide to Network Programming (http://beej.us/guide/bgnet/). The more Windows-specific route would be I/O Completion Ports, but I've never found a need to go that route.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Network programming Win32
SuPete
My question is if WinSock is the only alternative in C for Windows?

Well, it's the "only alternative" in some sense but keep in mind that the WinSock API actually has lots of ways of doing the same thing, so you can use blocking send/recv, non-blocking send/recv, window message notification, IO completion ports, etc., etc. So there's actually lots of ways you can program it even if you're just talking about WinSock.

If we were to implement networking in Handmade Hero, it would definitely be what we would use, and I'm guessing we would probably use non-blocking send/recv if we could get away with it because that is cross-platform and would save time on porting.

- Casey
Pete
22 posts
Network programming Win32
Thank you all for pointing me in the right direction, i guess i will start figuring out the WinSock API then.
Joel Davis
20 posts
Network programming Win32
I'll second what everyone said about Winsock, and that's a great choice if you want to stick with the "handmade from scratch" philosophy.

After reading through Beej's excellent guide, if you want something slightly higher level, I'd recommend take a look at enet (http://enet.bespin.org/) it takes care of a lot of the tricky bits and is geared towards games, without being too limiting.
Marco
10 posts
Network programming Win32
This is a more complex library, but it is opensource and worth a look at as it was developed for games:
https://github.com/OculusVR/RakNet

Also, Glenn Fiedler has a list of amazing posts on networking (no code though):
http://gafferongames.com/networking-for-game-programmers/
1 posts
Network programming Win32
Check this one....A simple Socket Programming sample

Chris
3 posts