I have a question about C# communication.
Currently using.Net and studying Socket. You can create a socket server using the internal IP and connect as an internal client. Is it possible to open a server in another network like a chat program and connect to Socket Ip:Port from another network?
Socket sListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse("192.168.0.20"), 8000);
sListener.Bind(ipEndPoint);
sListener.Listen(20);
Socket sClient = sListener.Accept();
Is there anything I need to configure to open the server using the above IP and port number and connect to the server from another network (Client)?
Thank you:]
Yes of course. I draw a little image for a normal connection over the internet.
60800
to 192.168.0.20:8000
.your-external-ip:60800
. Hint: 60800
can be any other random port-value. I suggest high random numbers, so that hacker/scanner can't discover your service so fast.
That is very basic. I recommend, that you start learn how the ip-communication is working.
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.