I have a .NET TCP client that sends large volumes of messages to a TCP server (.NET async).
I need to continue sending messages to the server, but because of TIME_WAIT, I have run out of ports on the client.
How can a program constantly and reliably send messages without using all available ports?
Is there a way to reuse the same socket. I looked at Disconnect () and the REUSEADDRESS socket flag, but did not find any good examples of their use. In fact, most sources claim that not using Disconnect is the same as for a lower level of use (i.e., it only processes the socket descriptor).
I think I need to switch to UDP or maybe there is a method using C ++ and IOCP?
You can leave the socket open if your server and client know the data format. You close the socket so that the server can “see” that the client is “done”.
If you have a protocol, then the server can “know” when it has finished receiving the data block.
You can find somekind message end token, you can pass the message length and read the rest based on size, etc. Different ways to do this.
But there is no reason to constantly open and close connections to the server - which kills you here.
Can your client just keep the same socket open and send messages in a loop?
open socket connection while(running) send messages over socket close socket connection
TCP . TCP- " ", . ACK , TCP , .., .
, TCP-. , , . , TCP- .
( ). HTTP- , ; , - , "" HTTP 1.1, HTTP TCP-.
- UDP. , , , - , - . , UDP, , .
.
, , .
, Async .NET. MSDN .
- ? , , , , , , , , , .
Google MSDN #.
TCP- ( ) - , .
open a server socket // this uses the port the clients know about while(running) client_socket = server_socket.listen fork(new handler_object(client_socket))
#.
Source: https://habr.com/ru/post/1697773/More articles:Date and time formats for different countries - localeUnfamiliar character in SQL statement - sqlWhat is the consensus on Voice Family? - htmlWhy can't I use the Template Toolkit? - perlDotNetNuke "keepalive" - asp.netЗависимости проектов от нескольких версий Visual Studio - visual-studioHow to create a WPF application where I can drag and drop a user control between windows? - user-interfaceDataSet Sync - sql-serverКак перенести среду с несколькими сайтами ClearCase/ClearQuest во все Open Source? - version-controlCosts vs. Assistant - databaseAll Articles