aspose file tools*
The moose likes Java in General and the fly likes How grab/listen to all outgoing data (on a socket?)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How grab/listen to all outgoing data (on a socket?)?" Watch "How grab/listen to all outgoing data (on a socket?)?" New topic
Author

How grab/listen to all outgoing data (on a socket?)?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I know this is a broad question and I'm not even sure I'm stating it properly, but basically here's what I want to do:

1. There will be programs that attempt to open a connection to outside sources (like an email client)

2. I want all data that they send over that line to be readable by my program without need to alter those programs

Is it possible to listen on outgoing ports? For example, if I'm at 111.111.111.1 and they try to send something to an outside computer at 222.222.222.2:25, how would I grab that "conversation"?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18139
    
  39

In terms of tools, you can use a commandline tool call "tcpdump" which will provide and filter all the traffic going on with a network card. The windows version of that tool is "windump". There is also a higher level tool, called "ethereal", which provides a GUI interface to "tcpdump" and "windump".

Now... In terms of APIs, these packages also have lower level libraries for applications to use. And I have seen some mention of a Java API around these libraries. I have *never* used "tcpdump" in a programmatic fashion, so don't have an opinion on the libraries.

But the "tcpdump", "windump", and "ethereal" tools, works as advertised and is great for debugging network programs.

Henry
[ November 02, 2006: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Michael McHugh
Greenhorn

Joined: May 30, 2006
Posts: 3
The tools listed above are all based on the same packet capture library, Libpcap (and it's Windows port, Winpcap). There are Java wrappers available for these libraries that you can use. The two that I know of are jpcap and Jpcap (same name, different projects). These provide an API to let you grab all traffic on the network, or filter based on destination address, port, protocol, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How grab/listen to all outgoing data (on a socket?)?
 
Similar Threads
Personal SMTP
How to write program that uses all memory available?
Socket design question
Listening to mouse motions outside the Window?
Need String program