C # section traversing IP to check whether the port is open

Cause the printer is used in the project, but not so wasted after each boot must assign the printer a fixed IP. IP printing paper information. Finally, out of paper, dense see IP address, so the initiation of the idea, through the ping ip IP found this printer.

Most begin with the bat 255 Ge ping command, but found through the ip port may not be opened. So check into a telnet ip port.

FOR /L %%i IN (1,1,255) Do ping 10.231.133.%%i -n 1 -w 300 | Find "TTL" && telnet 10.231.133.%%i 6101 && echo off

 

Go through the cycle ip ping 1-255 each ip, -w 300 represents a timeout, ping nowhere because of the relatively long ip.

Then get results if there is TTL, there is expressed ping through. Then we use telnet to check whether the port is open. Actually achieve the desired effect.

 

But for the port is not open ip, every time checking for 5-10 seconds. This leads to 255 IP, there are about a 50 ping is successful. But this 50, there are 49 ports did not open when using longer , 5-10 minutes.

So I finally decided to write their own programs, their own control check time, because telnet 1 Miao has not been possible to determine the basic results did not open the port.

 

The effect is as follows:

 

 

 

 

Source Address: Link: https://pan.baidu.com/s/1UdRUrBidPilrQx-VWf2B0Q extraction code: rn4b 

 

Guess you like

Origin www.cnblogs.com/cskk/p/11465426.html