简体   繁体   中英

Java TCP Client Server working over LAN with port Forwarding but not with hamachi

I have a basic Java Client Server TCP Programm which is able to connect over LAN and also when i use my public ip with port forwarding.

What bothers me, is that it does not work when i try to use the same programm inside of a hamachi VPN network. I want to get it to work there as well, as many people try to avoid port forwarding but use hamachi as it seems easier for them.

Server Code ss = new ServerSocket(4444); Client c = ss.accept();

Client Code Socket client = new Socket(, 4444); printWriter = new PrintWriter( new OutputStreamWriter( client.getOutputStream()));

I googled and could not find any information about this problem, as usual people ask how to avoid port forwarding and are told to use hamachi for example or learn how to forward their ports.

Thanks in advance!

Could hamachi actually be blocking a port? I like to use ncat and nmap to test for these things.

"ncat -l portNumber" will start a server listening on portNumber

"nmap -Pn -p1234 someHost" will see if port 1234 is open on someHost (without doing a ping to determine if the host is up first)

Setup the above with your server and client, try it for your port 4444 and try it with some ports that nobody blocks like 80 or 443. If it works for those normal ports, but not for 4444, then something (hamachi?) is blocking that port.

该错误是程序的另一部分确实关闭了某些流,并且在java中,关闭一个封装的流会关闭其下的所有内容。

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