Reputation: 61510
TCP allows one side to issue a "FIN", and have the other side respond with some data before ending its side of the connection.
How can I achieve this using .NET's TcpClient
? It appears that I must use Close
to issue a FIN, but after that I can no longer call Client.Receive
since Client
is set to null
by Close
.
Upvotes: 2
Views: 158
Reputation: 61510
The way to do this in .NET is to call
Socket.Shutdown(SocketShutdown.Send);
or, if you're using a TcpClient
:
TcpClient.Client.Shutdown(SocketShutdown.Send);
Upvotes: 0
Reputation: 311050
Issue a shutdown for output. That sends the FIN and stops you writing anything else but it leaves the other half of the connection open.
Upvotes: 2