🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

socket programming.

Started by
2 comments, last by Promiscuous Robot 23 years, 5 months ago
Hello, I''ve decided its time to really learn network programming. So my first project is a multiplayer Bridge or other type of card game. Looking through docs I find that there seems to be a sort of standard called Berkeley sockets, or BSD. Far as I can tell Windows adds its own stuff to the standard (eg. requiring a call to WSAStartup() as initialization). I''m looking to make this portable, so to avoid #ifdefs and incompatibilities further down the line I was wondering if there is an alternative implementation of sockets for Windows that is actually closer to the standard so I can code once, and compile x amount of times. And if anyone thinks I should tackle network programming differently than using BSD sockets, I''m open to that as well.
--------------------------I guess this is where most people put a famous quote..."Everything is funnier with monkey''s" - Unknown
Advertisement
BSD sockets are definitely the way to go! I''m not so sure about WinSock''s compatibility, but unless you use the WSAxxx stuff it shouldn''t be too problematic.

cu,
Prefect

---
Sanity is the trademark of a weak mind.
Widelands - laid back, free software strategy
I also agree that BSD sockets are the way to go. Unfortunately, WinSock (though being similar), isn''t quite the same. You can
avoid much of the "different" stuff by avoiding the Asynchronous commands (receiving Windows messages whenever data is sent to your machine). Even then, there will be incompatibilites, such as "close" being a different function.

Good luck!
The best way to create a portable socks class is to read what someone else did. I believe the most portable socket code I''ve ever seen is the circlemud code (www.circlemud.org, look in the comm.c and comm.h files). It compensates for various OS deficiencies (from solaris to mac to windows to linux) and creates a standard set of functions for the programmers. I suggest you use the examples provided in this code along with a socket tutorial to create your own Network class. Once you''ve made it, you''ll never have to make it again.
============================ Trevor "Zephyre" Barnett

This topic is closed to new replies.

Advertisement