TCP socket close problem
- From: Staffan Ulfberg <staffan@xxxxxxxxxx>
- Date: 16 Jun 2006 15:44:45 +0200
Hello,
Since my previous tcp issue was resolved by posting here, I'll try
again, this time with another TCP problem. If someone knows of a good
network programming group to post to instead, please tell me so!
I've written a server app that listens to port 5000 on a FreeBSD
machine. Connecting works fine, and actually everything usually works
fine, except when some clients disconnect. The client's socket is
closed, and does not even show up in netstat (the clients are Windows
XP machines). On the server, however, the socket stays open, in
"ESTABLISHED" state. (Not even CLOSE_WAIT.)
It would seem I'm doing something wrong, which prevents the server to
detect the closed socket, but I've added lots of trace output on the
server, and it does seem to set the client's socket descriptor in the
call to select(), but select() never returns saying that the
descriptor is readable.
The problem only happens when I client closes a "busy" socket, with
unacked data on the way to the client. And, as expected, the client
sends an RST after the FIN.
It all looks like I'm not properly detecting that recv() returns with
0 bytes (I think the server sends it FIN after close() is called on
the socket?), but I've scratched my head now for a long time...
Can somesone with more TCP experience help me think of possibilities
for this happening?
15:34:13.244087 IP 81-226-237-254-no61.tbcn.telia.com.2610 > multivac.fatburen.org.5000: . ack 699313 win 11680
15:34:13.256048 IP 81-226-237-254-no61.tbcn.telia.com.2610 > multivac.fatburen.org.5000: . ack 702233 win 8760
15:34:13.517164 IP 81-226-237-254-no61.tbcn.telia.com.2610 > multivac.fatburen.org.5000: F 118:118(0) ack 702233 win 8760
15:34:13.518210 IP 81-226-237-254-no61.tbcn.telia.com.2610 > multivac.fatburen.org.5000: R 119:119(0) ack 702233 win 0
15:34:15.199721 IP multivac.fatburen.org.5000 > 81-226-237-254-no61.tbcn.telia.com.2610: . 702233:703693(1460) ack 118 win 65535
15:34:21.275374 IP multivac.fatburen.org.5000 > 81-226-237-254-no61.tbcn.telia.com.2610: . 702233:703693(1460) ack 118 win 65535
15:34:29.953937 IP multivac.fatburen.org.5000 > 81-226-237-254-no61.tbcn.telia.com.2610: . 702233:703693(1460) ack 118 win 65535
15:34:47.115708 IP multivac.fatburen.org.5000 > 81-226-237-254-no61.tbcn.telia.com.2610: . 702233:703693(1460) ack 118 win 65535
15:35:10.040407 IP multivac.fatburen.org.5000 > 81-226-237-254-no61.tbcn.telia.com.2610: . 702233:703693(1460) ack 118 win 65535
BTW, I've tried reproducing the results on a Linux 2.6 server, but
somehow the code always works there.
Staffan
.
- Follow-Ups:
- Re: TCP socket close problem
- From: Per Hedeland
- Re: TCP socket close problem
- Prev by Date: Re: freeBSd for a 486
- Next by Date: kldload snd_driver fails on current
- Previous by thread: SNMP poblem
- Next by thread: Re: TCP socket close problem
- Index(es):
Relevant Pages
|