简体   繁体   中英

Connecting with computers outside the local network in Java

I found some basic examples online about sending messages between computers in Java. However i realized that i only used local ip addresses so i could only send messages to a pc connected in the same network. I rewrote most of the code to make a slightly better version but if i wanted to send a message to a computer in a different network, connected to the internet, would switching the local ip with the receiving computer's public ip address in the code do the trick?

简短回答: 是的 ,只要接收方计算机具有公共地址且没有代理阻止请求。

Yes it should work, however it's common place to connect to the Internet via a modem, which in term is the device holding the public IP. Some NAT and likely port forwarding would be needed at the endpoint.

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