I'm trying to send a data packet, and receive that same data packet, by a java program over a socket. The point is to measure the time it takes to go over the network and return to my program itself. I cannot use localhost "127.0.0.1". I cannot use my own IP address, because it causes a java.net.BindException
(with it saying the Address is already in use, which it is).
Is there any other way to do this? I thought maybe partially closing the socket using socket.shutDownOutput()
, but the problem is that I wish to send a lot of data packets, so the socket will need to listen to it synchronously.
Any way to do this? Send a data packet over a network and back to the same program/same IP Address.
Why not just have a client that echoes the data back to the server? Then you can bind it to any IP address.
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.