port already in use...
Hello all - This is my first post.
1. I tried to search this forum (i really did) but kept running into search term not long enough (4 words) even when my search was "port already in use exception", clearly longer than 4 words. Sooo, apologies if this topic already exists.
I am trying to write a small program to intercept data packets from an external server to a client on my computer (this is a windows client). This is nothing nefarious, but would be useful, and will be released as OS freeware.
Problem is that the only way to get the port number is to start the client - but then the port is in use and cannot be attached to without an exception being thrown. I am trying to use a proxy server setup here, but am not married to it. I am also a networking nubi, but fluent in Java.
Any and all ideas appreciated, and i will gladly get more detailed if need be.
Thankful for any response
Is there really no one who can answer this question? Did i make a faux pas in the wording? Is it just a stupid question?
Network analyzers like wireshark do this all the time, therefor it is possible.
I just want to capture data coming in on a port for analysis, without disrupting the dataflow. Is it really that difficult?
Thanks to any responders.
In order to do that you need to interface with much lower-level code than Java will allow (i.e. down in the OS transport layer).
You could set up a proxy in Java, listening or transmitting on a different port, but you would have to configure your other applications to use that port.
Thanks Orange Dog!
Thank you - I am also conversant in C, can you steer me in the right direction?
In order to packet sniff invisibly you need to hook into the OS's network stack. On Windows the various components are running as part of one or more Services. I imagine there'll be lots of security business to contend with too. Best of luck.
Thank you for the reply! I will check out jpcap...
Just had a look - this is exactly what i was seeking - Thanks!