Opened 17 years ago

Closed 17 years ago

Last modified 17 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:
Platform: All

Description

hrev24888

  • on qemu, client: connect failed: Connection refused

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 by kaoutsis, 17 years ago

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

comment:2 by axeld, 17 years ago

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.

in reply to:  2 comment:3 by kaoutsis, 17 years ago

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 :-)

by kaoutsis, 17 years ago

Attachment: net_sockets.diff added

comment:4 by axeld, 17 years ago

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.

in reply to:  4 comment:5 by kaoutsis, 17 years ago

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.