Daniel Wu
Daniel Wu

Reputation: 6003

how to get the client port of a URLConnection in java

Is it possible to get the client side port number of a URLConnection in java, I didn't find any method to do that.

edit: I am on client side. As java API said, it will try to use the same connection for any URL, just like set "keep-alive" to true. And I want to verify this by:

1: create a URL by using new URL(someurl)

2: create a second URL by using new URL(someurl), the same ulr

3: get the client port for both 1 and 2. If they are the same, then there should be the same connection, meaning java reuse the connect as setting keep-alive.

Upvotes: 1

Views: 907

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172438

Is it possible to get the client side port number of a URLConnection in java

No, it is not possible and there is no method through which you can get that.

Upvotes: 1

Singh123
Singh123

Reputation: 216

there is no such method in java.

Upvotes: 1

Related Questions