c# - The requested address is not valid in its context in TCP socket communication -
i want implement socket communication between 2 applications running on same pc. 1 of unity application (server). wrote following:
public class main : monobehaviour { // use initialization void start () { // set tcplistener on port 13000. int32 port = 8800; ipaddress localaddr = ipaddress.parse("192.168.1.1"); // tcplistener server = new tcplistener(port); tcplistener server = new tcplistener(localaddr,port); socket socketforclient; try { server.start(); socketforclient = server.acceptsocket(); if (socketforclient.connected) { print("connected"); } else { print("not connected"); } } catch (exception e) { print(e.message); } } // update called once per frame void update () { } } when starting game getting following: the requested address not valid in context. exception. help? ip / port should use if want server client run on same pc?
you can listen on 0.0.0.0 interfaces including loopback , external.
but if know same machine, use 127.0.0.1 pointing itself.
Comments
Post a Comment