java.net.Socket - Question

Hi,

  My webserver is listening to a port 80 for servicing the requests.

  But I want to write a program which will grab the information from the same port number. Can we do it ?

  What ever is being received at 80 I want to capture the bytes and dump into a log file. Is it possible to do it ?

  WIll you get already binded error by any chance. The program I want to write will also be a server program.
badamiAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
brlmutiaConnect With a Mentor Commented:
I haven't seen one written in Java.  But you can view these connections using TCPdump program.  Its source code is written in C and its free.
0
 
loumfCommented:
How about configuring your webserver to another port and then forwarding all requests from your server to that other port.
0
 
badamiAuthor Commented:
how do you forward the data from one to another ? So does this mean the server we have to write is a http server. What about load handling ?

i think it is a big flaw to modify the port number.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
loumfCommented:
You don't have to be and http server since you just forward your calls to the HTTP server and return whatever it returns.  In the meantime you can log all you want.

If you don't do this, then I'm pretty sure that the only way is to do some kind of packet sniffing which is pretty OS specific.  There are products that allow you to capture and log a port on your lan. snoop on Sun is one.  tcpdump is another.  

I assumed that this was for some kind of testing and wouldn't be used in production.  The logs will be tremendous for any production site.
0
 
badamiAuthor Commented:
Where can I find the TCPDump Program ?
0
 
brlmutiaCommented:
I have a copy with me here.  I can attached this file in an email to you if you send me your email address.  Send it to

    bernrewelmutia@skybiz.com
   
0
 
zia777Commented:
A Java Web Server by default runs on port no.8080.which is also 80.
 
  And  information about every request made to the server is stored into
 log files of the server namely
 1.access.log
 2.event.log
 
  we can directly use these log files to retrieve information.
 
  for further details contact zia777_ah@yahoo.com
 
0
All Courses

From novice to tech pro — start learning today.