how do i connect to the server socket using the ip address and port number( client is running on a different machine than server)

陌路散爱 提交于 2019-11-29 08:05:15

To connect in your code you use:

Socket socket = new Socket(server_IP,server_Port);

So you could use:

Socket socket = new Socket("192.168.1.4", 5555);

It looks like you have this in your code so I'm not sure what problem you're having.

Don't forget that you have to setup your router to forward ports if it is located outside of your local network.

http://www.wikihow.com/Set-Up-Port-Forwarding-on-a-Router

Don't forget that if you are running a firewall, this can also interfere with the connection.

Update /etc/hosts
Add following line

127.0.1.1 192.168.10.109

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!