Home > Net >  Consult the Socket client program design correctly handle with local port
Consult the Socket client program design correctly handle with local port

Time:12-14

I want to create a TCP client, the other party asked me to bring a fixed local port, and the program starts to take the initiative to connect each other (the other party may not boot), if is winform development, how to design reasonable?
Did I want to use a timer to keep connected to each other? That if I had, I will stop the timer? If the net is broken or shut down, what should I do with?
With local port connection, there will always be created also create the socket is not able to create, and after the close, the socket connection state if not immediately become false, the overall problem a lot of ah, the great god solution a humbug and provide a good client wrapper class, can deal with these exceptions and problems

CodePudding user response:

When you send the message to determine whether, even if there is no connection, this will do,

The other requires you to "take a fixed local port" what is the purpose of the? The communication protocol document in the discussion? If not clear, so you don't tube he first,

Local port may be a few minutes can release, this is very normal, you don't need to pipe it,

CodePudding user response:

So-called "with a fixed local port" is the server monitoring only there should be a fixed port development, because the client to initiate the connection request, don't know the server fixed port number must be no,

A PC machine one day have "many times" to launch the client visit, such as random access to a web page, if you like to listen to a music, and so on, if the binding "fixed local port" then go back to 50 years ago,

If entangled with what "fixed local port", then you can also write A service, A program that there are both server to monitor A port and the client in A random port is the default mode (operating system) connection, don't make what "fixed the local port of this sort of thing,"

CodePudding user response:

reference 1st floor interacting in a professional developer response:
when you send the message to determine whether, even if there is no connection, this will do,

The other requires you to "take a fixed local port" what is the purpose of the? The communication protocol document in the discussion? If not clear, so you don't tube he first,

Local port may be a few minutes can release, this is very normal, you don't need to pipe it,

No matter there's no way. He is the party a,

CodePudding user response:

refer to the second floor interacting in a professional developer response:
so-called "with a fixed local port" is the server monitoring only there should be a fixed port development, because the client to initiate the connection request, don't know the server fixed port number must be no,

A PC machine one day have "many times" to launch the client visit, such as random access to a web page, if you like to listen to a music, and so on, if the binding "fixed local port" then go back to 50 years ago,

If entangled with what "fixed local port", then you can also write A service, A program that there are both server to monitor A port and the client in A random port is the default mode (operating system) connection, don't make what "fixed the local port of this sort of thing,"

When is my client connect to the server to my fixed port
  •  Tags:  
  • C#
  • Related