c# - How to find the port at which the particular service is listening programatically -


i know service name. there option find port number @ service listening?

ps:

netstat -a -n -o give ip, port, pid

while

tasklist /svc /fi "services eq servicename" give, imagename, pid 

how merge results of both port of particular service.

here's way go:

  1. use this output of cmd command
  2. use this split each line substrings
  3. compare substring service name want, if same. pid of service.
  4. execute second command. parse it, portnumber

remark: wise compare string in same casing, either uppercase or lowercase strings before comparing

good luck


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -