Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2060 closed bug (invalid)

this client test program fails to connect to the server test program

Reported by: kaoutsis Owned by: axeld
Priority: normal Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

hrev24888

  • on qemu, client: connect failed: Connection refused

Attachments (1)

net_sockets.diff (7.3 KB) - added by kaoutsis 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by kaoutsis

on real hardware (hrev24888), connect() doesn't return

comment:2 Changed 11 years ago by axeld

Resolution: invalid
Status: newclosed

You're using something like this several times: struct sockaddr_in server_addr = {AF_INET, htons(serverPort)};

But this is wrong - the first member is sin_len, not sin_family. The code you probably copied that from is broken :-) BTW there is already a similar test app, called tcp_server.cpp, and tcp_client.cpp.

comment:3 in reply to:  2 Changed 11 years ago by kaoutsis

Replying to axeld:

You're using something like this several times: struct sockaddr_in server_addr = {AF_INET, htons(serverPort)};

But this is wrong - the first member is sin_len, not sin_family. The code you probably copied that from is broken :-)

or historic? :-) http://www.fortunecity.com/skyscraper/arpanet/6/cc.htm i made the corrections, and now the program runs fine on haiku, thanks! But i still can't find why linux had no complains with the historic implementation. (Before the corrections, linux had no problem; even then the connection was fine)

BTW there is already a similar test app, called tcp_server.cpp, and tcp_client.cpp.

Yes. That was my first network program; i wanted to try something different :-)

Changed 11 years ago by kaoutsis

Attachment: net_sockets.diff added

comment:4 Changed 11 years ago by axeld

The problem with using the {...} initialization is that it makes assumptions on how the sockaddr structure (or sockaddr_in) looks like. The result is that it may or may not work on a platform - it's like Russian roulette. The actual members and the order of the sockaddr fields is unspecified.

comment:5 in reply to:  4 Changed 11 years ago by kaoutsis

Replying to axeld:

The problem with using the {...} initialization is that it makes assumptions on how the sockaddr structure (or sockaddr_in) looks like. The result is that it may or may not work on a platform - it's like Russian roulette. The actual members and the order of the sockaddr fields is unspecified.

You are right. I'll keep that in mind, thanks.

Note: See TracTickets for help on using tickets.