Code portability Linux to Mac and back.

Steve smorrey at gmail.com
Mon Feb 5 03:48:48 MST 2007


Hello all,
I've noticed something odd while trying to port some code from linux to mac.
To be honest I'm not at all sure whats causing the problem and it's
likely something on my end.

Basically, I'm opening a UDP listener the polling it, should be a very
simple thing to do.
My original code is just the UDP listener from the Beejs Guide to
Network Programming, wrapped into a C++ class.
And oddly enough it works just fine in linux but breaks when brought
over to a OSX.

The break is occuring when I do the socket polling.  OSX appears to be
lying about the IP address of the sender and saying it's 0.0.0.0.
However in Linux the exact same code produces the correct result.
Oddly enough if I take the original listener.c

http://beej.us/guide/bgnet/examples/listener.c

and compile it using OSX, it does show the proper address.

This leads me to believe it's something wrong with my C++ class.
My Class though is just a super simple wrapper, and of course it works
in Linux, so I'm confused and lost at this point.

Here is a link to the file in question if anyone would like to have a look.
ftp://69.60.117.0/listener.h

But I'm also wondering if anyone is aware of network code porting
issues, when going between Linux and Mac.

Thanks in Advance!
Regards,



More information about the PLUG mailing list