Go send FIN package without calling Close()

220 views
Skip to first unread message

André Moraes

unread,
Oct 21, 2010, 8:52:14 AM10/21/10
to golang-nuts
I am working on a server implementation, that uses TCP for communication.

When the client send the data to the server, the server process it and
return the results but don't close the connection because the client
may have more data to send.

But even if I don't call the conn.Close() on the server, the server
sends an TCP FIN packet to the client (I checked that with the
Wireshark). So my question is why the server is sending that FIN
package?

--
André Moraes
http://andredevchannel.blogspot.com/

André Moraes

unread,
Oct 21, 2010, 9:01:33 AM10/21/10
to golang-nuts
Code: http://pastebin.com/k286A89k

2010/10/21 André Moraes <and...@gmail.com>:

Dave Cheney

unread,
Oct 21, 2010, 9:02:47 AM10/21/10
to André Moraes, golang-nuts
Any chance you can post the code ?

2010/10/21 André Moraes <and...@gmail.com>:

Dave Cheney

unread,
Oct 21, 2010, 9:10:41 AM10/21/10
to André Moraes, golang-nuts
Check line 69

for !exitLoop {
/// codes
69: conn.Close()
}

I don't think the exitLoop flag is needed, calling break (lines 51,
54, 63 and 67) will exit the for loop

Cheers

Dave

2010/10/22 André Moraes <and...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages