Communicating with an HTTP Proxy via a .NET TcpClient

前端 未结 3 2015
-上瘾入骨i
-上瘾入骨i 2020-12-24 09:39

How can I communicate through an HTTP proxy with TcpClient in C#, kind of like WebProxy when using HttpWebResponse?

3条回答
  •  执念已碎
    2020-12-24 10:20

    Well, TCP doesn't have anything directly equivalent to HTTP proxying. In HTTP, the client (generally) knows about the proxying - it talks to the proxy, and asks the proxy to connect to the real web server on its behalf.

    TCP doesn't define that sort of thing, so any proxying would have to either be transparent (i.e. something that a router or the operating system does without the client knowing, e.g. with iptables) or as part of the protocol on top of TCP (HTTP proxying is a good example of this, as is SOCKS mentioned in a different answer).

提交回复
热议问题