From: Lew Pitcher on
On June 7, 2010 03:16, in comp.os.linux.misc, dima_ben(a)ukr.net wrote:

> On 3 июн, 20:35, Lew Pitcher <lpitc...(a)teksavvy.com> wrote:
>> On June 3, 2010 13:36, in comp.os.linux.misc, dima_...(a)ukr.net wrote:
>>
>
> Thank you!
> Do not know why but seems my 1st reply on your answer was lost.

Nope. I saw it, and replied in message Message-ID:
<QwaOn.36300$rU6.11792(a)newsfe10.iad>

> So, writing it once again.

Can't hurt :-)

> I found that in my case it did not work because missing htons() call
> for a port number (as you mentioned):
>
> out_sock.sin_port = htons(port);

Yes. That's correct.

> But code with htons() does not work on Windows!

Hmmmm.... not according to MSDN. Many of the MSDN "how to write network
code" documents that I looked at (prior to my initial answer) include the
htons() call as part of their example code. See
http://msdn.microsoft.com/en-us/library/ms737625(VS.85).aspx
or
http://msdn.microsoft.com/en-us/library/ms738557(VS.85).aspx
or
http://msdn.microsoft.com/en-us/library/3thek09d(VS.80).aspx
for example.

> So, I have to use
>
> #ifdef _WIN32
> out_sock.sin_port = port;
> #else
> out_sock.sin_port = htons(port);
> #endif
>
> to keep it working on all platfroms.

Such is the way of cross-platform code.

I'm glad you got your code working on Linux, and know how to keep it going
on both Linux and Windows.

Glad to have been some help, as well.
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


From: realto on
On Jun 3, 2:35 pm, Lew Pitcher <lpitc...(a)teksavvy.com> wrote:

Brampton's lew pitcher, late of TDBank, is a domain thief.

For further info, check out: http://lewpitcher.ca

Or simply type "lew pitcher" into the google search engine.