简体   繁体   中英

TcpListener not working for other machine ip: System.Net.Sockets.SocketException (0x80004005)

I have created one TCP listener which works fine, if i set it to listen to an ip for current machine, where the listener application is running. But, when i set it to listen to an ip of some other machine, of same network, it throws exception

System.Net.Sockets.SocketException (0x80004005): The requested address is not valid in its context .

Is it like, TCP listener can listen only to ips assigned to the machine where its running? Could some one please explain this?

You are right: "TCP listener can listen only to ips assigned to the machine where its running".

TcpListener is a class to handle incoming tcp clients/requests... since you (should) have no idea about other machine's traffic, it is indeed invalid to use other IPs here.

You cannot handle requests targetting other machines ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM