When we create a Http connection using the class "HttpURLConnection", it seems that the client port is selected by system randomly. How can I specify a client port for a Http connection? For example, a client app(192.168.1.100:8000) wants to connect to a URL.
Let me make my problem simple, I create a simple java HttpConnection app to test Http Digest Authentication which needs two registers. First register reqeust sends out from app, and then receives a 401. Then 2nd register with authentication header sends out. But the problem is these two register need the same port on the client side while the system uses different ports each time(two instances of HttpURLConnection). And I don't know how to use one instance of HttpURLConnection to send 2 requests.
I try to use socket class but it still cannot let me specify the port on the client side.
Also, how to specify client port for Http connection in J2ME?
-----------------------------------------
Thanks a lot! & Merry Christmas!
Kevin,

Reply With Quote


