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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

brlmutiaCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.