简体   繁体   中英

Java - TCP connection

I am working now on simple program to send file through TCP using Java. I have a problem that I am not able to connect between computers ( I am testing application using router and local IP adresses).

I start connection by:

sendSocket = new Socket(sendIp, port);

and I am trying to recieve connection on next PC by:

servsock = new ServerSocket(port);  
recieveSocket = servsock.accept();

where port is 12222, sendIp is 169.254.5.47 ( second computer that recieves)

and myIP is 192.168.0.52 ( computer that sends)

What I am doing wrong?
I always use the same port, and I see on TCPView that java app uses that port. Maybe I assign wrong IP, or my firewall blocks somehow.

Best regards and thanks, Chris

If this is a Windows network, the IP 169.254.5.47 means the host did not obtain a valid IP address from the DHCP. In a standard local network both addresses should be on the same class C range (192.168.0.*).

You have to first solve this physical issue with your network and test it using ping (each host should be able to ping the other and see replies).

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