What port does httpclient use?
Solution 1
There are always two ports involved in a connection - one at the server, and another at the client.
The server-side port is specified (and is known to the client) via the HTTP URL (the default is 80 for HTTP connections and 443 for HTTPS) and is specified after the hostname using hostname:port notation.
On the client-side, things are a bit more interesting. Clients open a temporary or dynamic port that lasts only as long as the connection is made. Client-side ports are always opened on the dynamic range (49152 through 65535) reserved for them by IANA, which is usually enforced on the newer operating systems (I'm not sure if Windows XP follows the IANA directive to the letter, but Vista and Windows Server 2008 happen to).
Solution 2
If you mean the destination port, the standard for the non-secure (HTTP) protocol is 80, whereas the standard HTTPS port is 443.
In terms of the outbound client port, that's largely irrelevant and will be chosen based on what ports are available, etc. (i.e.: There's no set outbound port.)
Related videos on Youtube
Anon
Updated on July 09, 2022Comments
-
Anon almost 2 years
What port does httpclient use?
80, 8080, ....?
-
Ali Hidim over 13 yearsAt which end? The port of the server you connect to, or the port opened at the HTTPClient end?
-
-
Kato over 11 yearsThanks for the details; answered all my questions about what I need to allow on the firewall :)
-
kovac about 6 yearsYes, but not all client traffic is outbound right. After the client sends a HTTP request it's likely that the client will receive inbound payloads. I believe the question is about that.
-
choxsword about 2 years"Clients open a temporary or dynamic port that lasts only as long as the connection is made" : Does which RFC specify this convention?
-
Vineet Reynolds about 2 years@scottxiao Check RFC 6056. It covers recommendations for ephemeral port selection, and preferred ranges for such ports, among others.