March 4th, 2003, 09:05 PM
Port traffic help...
Hey guys, this is probably a really stupid question... but, I need some help.
I know, that when I go to a website, I am sending packets to port 80, their webserver. I know that when I go to an smtp server, I am sending packets to port 25.
But, when I send packets to a web server on port 80, am I receiving packets on port 80? And when I send packets to port 25, am I receiving packets on 25?
When I run netstat, I see that when I connect to a web server, traffic comes from port 80, and to a port like 3701.
I'm juuuuust getting into programming, and I was thinking about writing a very simple tcp/ip program, however, I don't know what port I should be listening to when I'm receiving packets.
I hope I made sence!
March 4th, 2003, 09:43 PM
When you read about connecting to servers and servers running on well known ports, those are destination ports. If you look at the header for tcp, you will see that there is both a source port and a destination port (these services that you mentioned are using TCP (transport control protocol)). Usually, whenever a client (that is what makes the connection to a server, think of your web browser or email client) makes a connection to a server, it choses its own local ephemeral (aka non-well known, aka non-reserved, which is any port > 1023, but more typically in the 30000-65535 range) as the source port and the destination port of whatever service you are connecting to...
A good tutorial on TCP/IP with connection establishment would probably be a good thing to read if you want to get into the nitty gritty...
Here is the actual paper on the standard for tcp.
There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.
(Merovingian - Matrix Reloaded)
March 4th, 2003, 09:52 PM
Yep, nebulus pretty much summed it up. Just because your destination port is 80, by no means, means the source port is 80. Usually your application will dynamically decide which port to use, and then it is the transport protocol's job to get port information across to the server.