If you only want to do simple things -- just connect, send, recv,
etc., not nonblocking/aio, not treating as fd including fdopen and
passing to a child -- Unix (Berkeley) sockets and winsock can be
source compatible except for WSAStartup (and WSACleanup, which is no
longer really needed), a few typedefs names especially sd/SOCKET, and
the #definable errno location.
Your question is off-topic here, as are all questions about sockets.
(Standard) sockets belong AIUI in comp.unix.programmer; I don't know
where, if anywhere, directly addresses Berkeley vs winsock, although
my newserver lists a few winsock groups that sound like prospects.
FWIW, You may be able to write the code unix style, then use the mingw or
cygwin environment to compile the code for windows. If you search the web
on mingw and cygwin you should get plenty of hits.
Cygwin probably; mingw with only a few exceptions uses and exposes the
underlying Windows/MSC libraries, including winsock, and thus is no
more compatible than straight Windows code is (as above).
There's also a chapter in the book "C unleashed" which deals with this
issue.
Hence coming back almost on topic. :-?
To get a better idea of what is and what is not on topic here, you can
read the clc faq here:
http://www.eskimo.com/~scs/C-faq/top.html
Actually that's not a good reference for topicality; it doesn't
discuss such directly at all, and if you try to deduce from cases, it
includes a number of system specifics, plus some things that are not
really about C programming, which *are* or were frequently asked even
though off-topic.
http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html
is simpler and clearer on topicality, and related netiquette.
- David.Thompson1 at worldnet.att.net