Sockets Function Names

Started by
3 comments, last by WebsiteWill 20 years, 10 months ago
Been hassling with either dual booting Unix, running VMWare or Cygwin and any other method I can think of when I just read this. From what I understand, Winsock is identical to regular Unix sockets except some of the function names and parameters are different and Windows sockets need to be initialized and destroyed correct? So, for me to be able to follow the examples in the book Unix Network Programming would it be possibly to use VisualC++ and simply do something like initialize winsock and write the file like normal except maybe wrap all necessary winsock functions work the same way as unix sockets? This would allow me to enter and work with code directly from the book, (essentially writing code for Unix Sockets). Seems then that if I wanted to actually run on Unix it would jus be a matter of swapping out some include files and getting rid of the Winsock initialization. As I write this it occurred to me that the way Windows and Unix handles multiple threads, forks, processes, etc might play a very large part in how this works and may indeed not let it work at all. Input appreciated, Webby
Advertisement
Windows uses the BSD socket API with small changes. As long as you stay away from signals and fork/exec designs, you can map most everything else between the two OSes. I''m assuming you are designing from scratch (or almost) because porting a Unix app that uses fork/exec to Windows is a _BIG_ mess.

Your major issue will not be about using a constrained set of the API, but having the more advanced features such as async I/O and IOCP/aio out of immediate reach; those, of course, happen the be the most performant paradigms.

Here are a few of the gotchas you need to be careful with when porting to NT:

byte ordering

int vs SOCKET

64 socket limit on select()

OOB''s one byte offset using TCP

Can''t use anything _BUT_ a socket with select()

WaitForMultipleObject() can''t work with with un-connected TCP sockets.

closesocket() instead of close()

return values of most functions (SOCKET_ERROR/-1)

general error codes (WSAGetLastError()/errno)


-cb
I figured as much about the fork commands and such. Looks like I''ll just dual boot Red Hat or something and work from there. Just need to figure out how to dual boot this machine in a way that my other windows machine can still have internet access through the host/server.

Thanks,
Webby
Good grief. Can''t you Red Hat guys out there make installing a little bit easier? I mean, come on...I''m a gimp from the Windows world. I expect everything to be done for me at the click of a button.

Seriously though. I''m reading on how to configure Linux to access the internet and there sure seems to be a lot of BS required to get it running. At least the tutorials I am trying to read are very confusing. Call your ISP and ask for a specific IP address to use? I haven''t even installed Linux as a dual boot yet because every tutorial I read says to do something different and generally require a fairly strong knowledge of Linux in the first place. Sheesh. I''m beginning to think that just developing this on Windows and assuming the extra expense will be AOK for me.

Webby
about the original question, I would wrap them so I just have to recompile to use it on either system. You can do this using macros and precompile directives, like #if ..., to map it to the function that exists in the os you are compiling to ... Of course the problem using macros is that it is harder to spot places where you do mistakes, so instead you can use functions instead (just stick to either style and define the functions when you are in the other os )
Eglasius - I can see how the power flows within you, open your eyes and live in a new world.

This topic is closed to new replies.

Advertisement