Click to See Complete Forum and Search --> : cross platform sockets


hspc
March 18th, 2005, 06:35 AM
Hi
I want to make a simple application that uses sockets.
This application should be cross platform (mainly should run on Windows / redhat Linux/ fedora) ..Or at least it should be ported easly...
What socket libraries should I use ? can BSD sockets work for both platforms ?
Or must I wirte the windows version using winsock ?
Any suggestions / comments are welcome... :wave:

ahoodin
March 18th, 2005, 08:22 AM
I actually suggest using the pre-processor for this.

You can :
#define MSWINDOWS 1

and later:


#ifdef MSWINDOWS
//winsock only needed for windows, not free BSD or LINUX
#pragma comment (lib, "ws2_32.lib")
#endif


using different #defines for different builds. In other words you can use seperate verbose for each OS yet in the same file with partially the same code. Just use #ifdefs where the syntax differrs.

This way you can maintain one codebase for your cross platform application.

HTH,

ahoodin

PS Don't forget to rate.

kuphryn
March 18th, 2005, 06:28 PM
I am not familiar with the Berkeley Socket. I do know a cross-platform C++ library though. Check out Trolltech's Qt.

Kuphryn

hspc
March 19th, 2005, 03:25 AM
Hi
As far as I know..Qt is a cross platform GUI library.
I don't think it contains sockets.

Andreas Masur
March 19th, 2005, 04:22 AM
Well...as long as you use raw windows sockets (not the MFC wrappers etc.) you are fine. You simply need to link the appropriate library depending on the system.

Other than that you might want to take a look at the ACE framework (http://www.cs.wustl.edu/~schmidt/ACE.html)...

kuphryn
March 19th, 2005, 12:03 PM
Check out Qt's QSocket.

Kuphryn

hspc
March 19th, 2005, 02:26 PM
Well...as long as you use raw windows sockets (not the MFC wrappers etc.) you are fine. You simply need to link the appropriate library depending on the system.
Great.. :thumb:
seems I'm going to use this way :)
thanks