I use TCP sockets to transfer data between the server and the client program using a specific port number on one computer (localhost).
Do I need software that can capture data sent / received through this socket?
(or)
What is the easiest way to sniff packets from a specified port in Java?
I suggest using Wireshark. It is easy to use and works on many platforms.
http://www.wireshark.org/
- ( wirehark/tcpdump), . Java, (?) - JNI, , , :
- InputStream/OutputStream -, / , "" /.
InputStream
OutputStream
, .
, netcat. , ..
HTTP- ( Firefox ), , .
Tcpdump , , wireshark. -
Tcpdump
wireshark
tcpdump -ni lo0 port 1234
, (lo0 - loopback Unix/Linux, , , ).
:
java -Djavax.net.debug=all helloworld.java
Oracle JSSE
java.net.*
You can use tcpdumpone that provides you with many options. You save the capture in a file .pcapwith the -w option, and when you are done, you open that file with wireshark. The advantage of this method is that you can capture high packet rates per second without affecting the overall performance of your computer (even if it is low).
tcpdump
.pcap