LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Getting Port on which client is listning from the client program. (https://www.linuxquestions.org/questions/programming-9/getting-port-on-which-client-is-listning-from-the-client-program-247418/)

rasanth 10-26-2004 06:10 AM

Getting Port on which client is listning from the client program.
 
All,
After the client connects to the server, is there any way by which I can know , on which port the client is recieving(on the client side) data from the server?
Thanks in Advance,
Rasanth

acid_kewpie 10-26-2004 07:10 AM

use a tool like ntop or ethereal to listen to the traffic

Hko 10-26-2004 11:23 AM

Code:

netstat -plant | sed -n 's/[^:]*:\([0-9]*\) .*firefox.*/\1/p'
I used "firefox" here to test. Replace "firefox" in the above example with the program name on the client you want the port number of.

I find "netstat -plant" an useful command for finding info on TCP connections (and easy to remember).


All times are GMT -5. The time now is 08:00 PM.