#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
- on qemu, client: connect failed: Connection refused
Attachments (1)
Change History (6)
comment:1 by , 17 years ago
follow-up: 3 comment:2 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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 by , 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 , 17 years ago
Attachment: | net_sockets.diff added |
---|
follow-up: 5 comment:4 by , 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.
comment:5 by , 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.
on real hardware (hrev24888), connect() doesn't return