Sockets in general

Started by
2 comments, last by gimp 23 years, 12 months ago
I was wondering, do any of you guys have experience with writing Win AND Unix sockets apps? Just a curious question as I''m about to start working on my multiplayer code and wan''t to make sure I don''t paint myself in to a corner for when it comes time to port the code to linux. Are there any thing''s I shouldn''t do with winsock that''ll make it harder to convert later? Is there anything I shouldn''t do in C++ like using basic_strings etc? chris
Chris Brodie
Advertisement
If you are using WinSock, it''s the exact same sockets as Unix (all Berkeley).
I came along just in time... I have the same question. I heard somewhere that you can''t use WSAStartup() with linux, is that true?

--------------------


You are not a real programmer until you end all your sentences with semicolons;

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Any function beginning with WSA is Winsock specific, i.e. not in Berkely sockets. Because of the tight integration of the Berkeley socket architecture with the UNIX architecture it''s not necessary to perform the same kind of initialization with Berekley sockets. Berekley sockets are acutal file descriptors, Winsock sockets are essentially Window''s HANDLES.

To make it easier to code for linux later, don''t use WSAAsyncSelect. select or WSAEventSelect is fine, especially if multi-threading. However your WSAEventSelects will have to replaced by select statements, and you''ll block on those rather than on the event objects. Stick with standard I/O functions, send(), recv(), sendto(), recvfrom(), as the overlapped and extended versions aren''t available on UNIX boxes. Also note that FD_SET is a structure in Windows but is a typedef of a primitive type in UNIX.

This topic is closed to new replies.

Advertisement