Java TCP Socket Sniffing

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?

+5
source share
7 answers

I suggest using Wireshark. It is easy to use and works on many platforms.

http://www.wireshark.org/

+7
source

- ( wirehark/tcpdump), . Java, (?) - JNI, , , :

+4

- InputStream/OutputStream -, / , "" /.

, .

+1

, netcat. , .
.

HTTP- ( Firefox ), , .

+1

Tcpdump , , wireshark. -

tcpdump -ni lo0 port 1234

, (lo0 - loopback Unix/Linux, , , ).

+1

:

java -Djavax.net.debug=all helloworld.java

Oracle JSSE

:

  • , ( )
  • / TLS/SSL:)

:

  • , java.net.* . OutputStream InputStream , . .
  • , Oracle JDK.
+1

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).

0
source

All Articles