john@iastate.edu (Hascall John Paul) (08/30/90)
Given the following code:
[... socket(), getservbyname(), sin <- values ...]
while (connect(s, &sin, sizeof(sin)) < 0) {
perror("connect");
if (++retry > RETRY) exit(1);
sleep(2);
}
If the server (to which I am trying to connect) is not there, I get:
connect: Connection refused <-- expected
connect: Invalid argument <-- WHY??
:
:
connect: Invalid argument
What am i forgetting here?
Thanks,
John Hascall / john@iastate.edu / hascall@atanasoff.cs.iastate.edu
dls@mentor.cc.purdue.edu (David L Stevens) (08/30/90)
If memory serves, a failed connect(2) in 4.2 systems would leave the socket in an unusable state. The fix is to close the socket and start all over from socket(2). We had this problem once upon a time too... -- +-DLS (dls@mentor.cc.purdue.edu)
ted@ultra.com (Ted Schroeder) (08/31/90)
In <1990Aug29.212123.12889@fs-1.iastate.edu> john@iastate.edu (Hascall John Paul) writes: >Given the following code: > [... socket(), getservbyname(), sin <- values ...] > while (connect(s, &sin, sizeof(sin)) < 0) { > perror("connect"); > if (++retry > RETRY) exit(1); > sleep(2); > } >If the server (to which I am trying to connect) is not there, I get: > connect: Connection refused <-- expected > connect: Invalid argument <-- WHY?? > : > : > connect: Invalid argument >What am i forgetting here? My manual page (SunOS 4.0.3c) says you get EINVAL when "namelen is not the size of a valid address for the specified address family". I'd guess that the connect mucked up the sin somehow. Ted Schroeder ted@Ultra.com Ultra Network Technologies ...!ames!ultra!ted 101 Daggett Drive San Jose, CA 95134 408-922-0100 Disclaimer: I don't even believe what I say, why should my company?