Home > Net >  Csharp port how to use the bat command to shut down inside.
Csharp port how to use the bat command to shut down inside.

Time:11-04

Csharp application of everyone, I used inside the httpserver began to a port,
In the system, I hope that bat command to shut down the program (taskkill) and then restart the program,
Results old remind program errors, because port is being used, that is to say, bat command to shut down the program, the port is not closed,
Excuse me, what can bat command at the time of closing procedures, close the program using port, thank you.

CodePudding user response:

Try Application. Restart ()

CodePudding user response:

A service binding local port, when the normal service stops, the port should be released, but you use the taskkill, belong to the emergency stop, so the port will not be released immediately, need to wait for a while to release, because the operating system needs to do some cleaning up for abnormal operation, ensure that residual TCP packets on the network can be handled correctly, avoid the client connect to bring session error, should be used normal.net stop command or sc command to stop the service,

CodePudding user response:

Problem:

When restart the tomcat service, start-up failure, according to the information is about: the Error running 'cus_manager_system: Unable to open the debugger port (127.0.0.1:52022) : java.net.SocketException "socket closed"

(English probably similar to this, the reason for failure is that you want to use the port number is occupied, my mistake was a port is occupied by a navicat)

A: the solution:

1. Find takes up the process of the port number: netstat aon | findstr searches "59207"



2. Check the process of application: tasklist | findstr searches "1396"



3. Then close the application, after waiting for tomcat successfully launched, and then opens navicat (navicat don't know how to take up)



2: sometimes a kind of situations: port being used, with the first step of the above query, they have not find any take up this port applications;

At this point, you can adopt the method of bottom, forced close your Java service, open the task manager, the diagram below:



Then, right-click to turn off this process, press the keyboard j found under a Java service, until close all), run the service again, can normal boot.
  •  Tags:  
  • C#
  • Related