Hi,
You can write completely portable code for sockets. The difference is that
windows in addition to the 'regular' calls for sockets also has some
special stuff that integrates with windows itself. For instance normally
you would create a bunch of sockets and start listening on them. In a
single threaded app that means it wouldn't respond to windows messages .
So windows added its own sockets to remedy that problem. However you just
use the portable sockets all you have to do is start it in a separate
thread and let the main thread handle the message queue while the separate
thread will do a (blocking or blocking with certain timeout) 'select()' on
the portable sockets. My network code works on various unix/linux as well
as on windows without problems.
Well having that said, I had a quick look in my code and there are some
very minor differences (not sure if they are actually necessary).
To get the error code
#ifdef WIN32
ErrorCode << Error << " " << WSAGetLastError();
#else
ErrorCode << Error << " " << strerror( errno );
#endif
And also if you use windows sockets you have to call some function one
time in your program on startup and on exit (something like
WSAInitialize()/WSACleanup() or something) (I am too lazy to look it up
right now :-) )..
Regards, Ron AF Greve
http://informationsuperhighway.eu
"Rayne" <lancer6238@gmail.com> wrote in message
news:dfd73693-1952-4e5d-9eac-656d587e804c@q40g2000prh.googlegroups.com...
Hi all,
I'm interested to know what is the difference in programming using MS
Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
are some of the things I can do on Visual C++ that won't compile/run
on Linux, and vice versa.
For example, I know that Windows uses the LLP64 model, while Linux
uses the LP64 model, so I can't use the long long data type when
programming on Linux. Also, the windows.h file is only available in
Windows, and can't be used on Linux. I've also read that there is also
some differences in network programming, since winsock, and especially
the underlying ip headers are much different in Windows than Unix/
Linux gcc. Is this true?
Thank you.