• Advertisement

Archived

This topic is now archived and is closed to further replies.

Sockets in general

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

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

Share this post


Link to post
Share on other sites
Advertisement
If you are using WinSock, it''s the exact same sockets as Unix (all Berkeley).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement