I am trying to make a server & client app that sends pictures over p2p to a specified host.
In this case I am using my own PC as the host and client, trying to establish a connection through my external IPs (not local).
However, I keep getting the error
system.net.sockets.socketexception the requested address is not valid in its context
This is how I try to set up the host:
Sock = new Socket(IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
SocketPermission permission = new SocketPermission(NetworkAccess.Accept,
TransportType.Tcp, IP.ToString(), m_Port);
//IP = IPAddress.Parse("0.0.0.0");
IP_EndPoint = new IPEndPoint(IP, m_Port);
and in another listener method, I have a listener socket:
Socket listener = new Socket(IP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(IP_EndPoint);
I had tried once with the IP set to 0.0.0.0, in which case it did start listening, but didn't receive anything.
I am using port 80. Before that I tried a different, unused port on my machine, something like 33338 etc, no luck.
What am I doing wrong here? (firewall is not the problem)