We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Network Sniffer prog needed

mravell asked
Medium Priority
Last Modified: 2010-08-05
Hi C gurus,

This Q is sort of a cross post as I asked it in the CGI area but didn't have much luck. (only unix heads about and while I am a fan of unix I need something that will compile under Micro$oft NT for my laptop).

Does anybody have a utility sitting in their toolbox which listens to a specified port (80 for my web work) and sends everything to the standard out?

Something nice and simple that I can have running in a DOS session would be perfect. No rocket science required. I need to debug some progs (CGI etc...) and do not have anything on hand that will give me this level of access to the network.

Source would be nice so I can fiddle with it (and maybe learn a thing or two about network programming..)

Watch Question


Hi tflai,

I checked this stuff out but was really after something that isn't a commercial / pay through the nose type application.

My needs are very modest.

Monitor Port x (80) and dump everything to standard out.

I don't need a high-end monitoring package, just a scrap of C code that somebody may have lyig around.


Socket Spy is a shareware.  And as far as I know, there are no full-fledge network snooper source code free anywhere.
It is not too difficult conceptually to implement a network snooper.  What you need is a promiscous protoocol driver and a application-layer shell that interact it through device I/O control and decode the packet headers for different protocols:  802.3, IP, TCP, ...  But to actually develop it is another thing...
But if you want a Winsock API snooper, I know where you can get a skeletal code for Winsock DLL replacement.

I'll second tflai's comments here but add a couple of points.  The only free network sniffers that I've seen are for MSDOS and unix/Linux systems.  In fact, there are several really good ones under Linux.  Under Windows, however, there is nothing in the low-price or free range.  


What I am after is more of a code snippet than a full package. I don't need any whistles or bells. Just something that listens to port 80 and dumps what it hears to the standard out.

No analysis, fancy graphics or logging features just a few lines of code that can eavesdrop on my own webserver.

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Hi Gadio,

An interesteing idea. Not exactly what I had in mindbut it sounds as if it could do what I am after.

Please comment the code.


Here it is. For each connection that takes place you get a window opened and shows you the in and out going data. Note that when you monitor http protocol, the client will probably open connection for each image that is on the page. Pages with many images on them will couse a lot of windows to be opend.
Enjoy, G.

------------- snooper.java --------------

 * Program: snooper.java Written by gadio.
 * This program opens a window for each connection to a the port
 * that it bridges. The window have one area for the input and one
 * for the output. Once the communication in finished a close button
 * is enabled.

import java.awt.*;
import java.net.*;
import java.io.*;

public class snooper {

    public snooper (int origport, int newport ) {
        try {
            ServerSocket srvs = new ServerSocket( newport );
            while(1) {
                Socket inconnect = srvs.accept();
                Socket bridge = new Socket("",origport);
                snooperObj so = new snooperObj( inconnect, bridge );
        } catch( IOException e ) {

    public static void main(String args[]) {
        snooper snoopy = new snooper(80, 1234);

class snooperObj extends Frame {
    private Thread inMonitor, outMonitor;
    Socket inconnect;
    Socket bridge;
    TextArea in_txt, out_txt;
    connector con1, con2;
    Button close, clearin, clearout;

    public snooperObj( Socket incon, Socket brdg ) {
        inconnect = incon;
        bridge = brdg;
        setLayout( new BorderLayout());
        in_txt = new TextArea( 20, 20 );
        out_txt = new TextArea( 20, 20 );
        Panel north = new Panel();
        Panel center = new Panel();
        north.setLayout( new GridLayout(2,2));
        center.setLayout( new GridLayout(1,2));
        String time = (new java.util.Date(System.currentTimeMillis())).toString();
        north.add( new Label("into server ("+time+"):"));
        north.add( new Label("out from the server:"));
        north.add( clearin = new Button("Clear input"));
        north.add( clearout = new Button("Clear output"));
        add("North", north);
        add("Center", center);
        add("South", (close = new Button("Close window")));
        con1 = new connector( incon, bridge, in_txt, close );
        con2 = new connector( bridge, incon, out_txt, close );

    public boolean handleEvent( Event e ) {
        if( e.target == close ) {
            con1 = null;
            con2 = null;
            return true;
        if( e.target == clearin ) {
            return true;
        if( e.target == clearout ) {
            return true;
        return false;

class connector extends Thread {
    Socket from, to;
    TextArea txtout;
    Button end_button;

    public connector( Socket from_s, Socket to_s, TextArea txta, Button closeb ) {
        from = from_s;
        to = to_s;
        txtout = txta;
        end_button = closeb;

    public void run() {
        try {
            InputStream is = from.getInputStream();
            OutputStream os = to.getOutputStream();
            while(1) {
                int b = is.read();
                txtout.append( ""+(char)b );
        } catch(IOException e) {

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.