views:

197

answers:

1

How to open socket thru proxy server in .Net C#?

So I opened up a socket on my machin. there are no nats between pe and proxy server. I connected to proxy server. How now to make Requests from global IP world that know that proxy server adrress be redirected or transfered by proxy server to me?

Any libs blog articles? Please help

+1  A: 

You cannot open a socket 'thru' something, only 'to' something. With proxy server (I assume you're talking about HTTP proxy that support 'CONNECT' command) it's the same: first open a connection to it, than use its protocol to make proxy forward your connection where you want to using 'CONNECT' command.

So you need to do the following steps:

  1. Connect to proxy.
  2. Issue CONNECT Host:Port HTTP/1.1<CR><LF>
  3. Issue <CR><LF>
  4. Wait for a line of response. If it contains HTTP/1.X 200, the connection is successful.
  5. Read further lines of response until you receive an empty line.
  6. Now, you are connected to the outside world through a proxy. Do any data exchange you want.
Haspemulator
So I opened up a socket on my machin. there are no nats between pe and proxy server. I connected to proxy server. How now to make Requests from global IP world that know that proxy server adrress be redirected or transfered by proxy server to me?
Blender
Well, when at step 2 you say CONNECT ..., you're opening a connection to some remote host. You connect to it, not vice versa. And when you're connected - step 6 - on the remote side there's an opened socket that remote side can use to send data to you.
Haspemulator