开发者

In Windows, how do I find out which process is on the other end of a local network socket?

That is to say, if I have a server listening on 127.0.0.1, and a TCP connection comes in, how can I determine the process id of the client?

Also if there isn't an API for this, where would I be able to extract the information from in a more hackish manner?

(The purpose of this is to modify a local HTTP proxy server to accept or deny requests based on the requesting process.)

Edit: palacsint's answer below led me to find this answer to a similar question which is just wha开发者_如何学编程t's needed


netstat -a -o

prints it. I suppose they are on the same machine becase you are listening on 127.0.0.1.


The only way to do this is if the connecting process sends some sort of custom headers which contains identifier. This is due to the fact that the networking layer is completely separated from the application layer (hint: OSI MODEL. This way it is possible to write lower layers software without caring what happens above as long as the messages exchanged (read: networking packets) follow a pre-determined format (read: use the same protocol).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜