Eeep, I should have tested it before I replied. My apologies. You're
100% right, the disconnects I described appear make read() return 0 with a
"resource temporarily unavailable" message on my system.
The message you're getting occurs when the server receives an RST
segment instead of a FIN. This might occur exactly as your player
described, when the client app crashes because the connection is killed
without doing a normal close(). This could also happen more frequently with
Win apps because of the difference in how sockets are handled in Windows and
UN*X but that's just a hunch.
As per your original question, you can try this: write a quick client
app that connects to your MUD port, sets SO_LINGER and then closes. That
may generate the RST you're looking to reproduce. As I said before, stock
ROM 2.4b6 handles this ok. The only real difference I see between stock
code and the snippet you included is that you're using recv() and the stock
code uses read(). I was under the impression that you should use recv()
with connect() but I'm no expert. You can always try switching it to read()
(since you're not passing any flags to recv() anyhow) and see what happens.
Just a shot in the dark. Hope this helps.
----- Original Message -----
From: "Jason Gauthier" <[EMAIL PROTECTED]>
To: "'Will Hongach'" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Monday, June 02, 2003 10:01 PM
Subject: RE: The mysterious of 'connection reset by peer'
> I appreciate your response. Unfortunatly, it's not entirely accurate.
>
> When a client's socket closes read() or recv() returns 0.
> If an error occured, -1.
>
>
> Bit of code:
> nRead = recv( d->descriptor, buf + index, sizeof(buf) - 10 - index, 0);
> if ( nRead > 0 )
> {
> index += nRead;
> bytes_received+=nRead;
> mrtg->bytes_received+=nRead;
> if ( buf[index-1] == '\n' || buf[index-1] == '\r' )
> break;
> }
> else if ( nRead == 0 )
> {
> sprintf(site, "Disconnection: EOF[%i]: '%s'", d->descriptor,
d->Host);
> logfile(site);
> wiznet (site, NULL, NULL, WIZ_SITES, 0, 208);
> return FALSE;
> }
> else if ( errno == EWOULDBLOCK )
> break;
> else
> {
> perror( "Read_from_descriptor" );
> return FALSE;
> }
>
>
> When recv() return a positive number, it processes the data.
> If it returns 0, the client has disconnected (as you've stated) This is
> normal.
>
> When it return < 0 an error occurs. This is what is happening to me. The
> error is "connection reset by peer". Errno is 104.
>
> Any other suggestions?
>
>