views:

34

answers:

2

I need to set the port of a HttpRequest. This is the port the Request is coming FROM.

Normal HTTP scenario:

Request: 127.0.0.1:6745 --> www.stackoverflow.com Response: 1227.0.0.1:6745 <-- www.stackoverflow.com

Request: 127.0.0.1:8096 --> www.stackoverflow.com Response: 1227.0.0.1:8096 <-- www.stackoverflow.com

My scenario:

Request: 127.0.0.1:6745 --> www.stackoverflow.com Response: 1227.0.0.1:6745 <-- www.stackoverflow.com

Request: 127.0.0.1:6745 --> www.stackoverflow.com Response: 1227.0.0.1:6745 <-- www.stackoverflow.com

The request must always come from a defined port. Is this even possible in the HTTP protocol? If yes, how do I use the WebRequest class in the .NEt framework? Or do I have to use manual sockets?

+1  A: 

What do you mean by requesting port? If it is the temporary port assigned by the OS I don't think that you have any control over it with WebRequest. IMHO it would be better to leave this management to the operating system or you could run into some conflicts with other applications.

Darin Dimitrov
A: 

What you are asking is impossible. I suggest you do some reading about the nature of TCP/IP.

spender