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?
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.