可在Telegram上免费试用:法国 、英国 或新加坡 加入Telegram
Proxy Fundamentals

HTTP vs SOCKS5 Proxy: Handshake & Wire Specs

HTTP CONNECT and SOCKS5 compared at the byte level: round trips before the first byte, the ATYP byte behind socks5h, how each authenticates, and why neither encrypts the hop to the proxy.

PXM2 Learn September 5, 2026 阅读需9分钟
RFC 1928 SOCKS5 binary
RFC 7231 CONNECT tunnel
socks5h Remote DNS safe
7+ PXM2 locations
  • OSI layer difference — Layer 7 HTTP parsing vs Layer 5 SOCKS5 session relay.
  • Handshake mechanics — HTTP CONNECT text pipe vs RFC 1928 binary state machine.
  • DNS leak prevention — why socks5h:// remote DNS (ATYP 0x03) protects your real IP.
  • Transport protocols — TCP byte stream tunneling vs SOCKS5 UDP ASSOCIATE.
Protocol Mechanics RFC Standards
HTTP protocolPlain HTTP & CONNECT byte pipe
SOCKS5 protocolBinary state machine (RFC 1928)
UDP forwardingSupported via UDP ASSOCIATE
PXM2 port pairBoth protocols on every modem
HTTP / HTTPS CONNECT: Universal Fit

Understood by every browser and HTTP library; optimal for web automation.

SOCKS5: Protocol Agnostic

Relays arbitrary TCP and UDP payloads neutrally without header parsing.

Almost every comparison of these two protocols scores them on speed and security, and almost every one of those scores is invented. Both protocols spend a handful of bytes agreeing how to open a connection and then get out of the way entirely. What actually differs is what happens during those bytes — and there are exactly three consequences worth knowing.

An HTTP Proxy Is Really Two Different Things

The phrase “HTTP proxy” names two behaviours that a comparison article usually blurs together. In the first, the client sends an ordinary request whose request line carries an absolute URI rather than a path, and the proxy is a full participant: it parses your headers, may cache the response, may filter it, and may add its own — a Via header naming itself, an X-Forwarded-For carrying your address. This is a forwarding proxy, and it reads everything.

In the second, the client sends CONNECT with a host and port instead of a URL, and asks the proxy to stop being an HTTP participant. RFC 9110 defines what happens next in unusually plain language: after a 2xx response the proxy becomes a tunnel that acts as a blind relay between two connections without changing the messages, and once active a tunnel is not considered a party to the HTTP communication at all. The specification even names carrying TLS through a shared firewall proxy as the point of the mechanism.

The whole of an HTTP CONNECT setup, typed at a socket
> CONNECT example.com:443 HTTP/1.1
> Host: example.com:443
>
< HTTP/1.1 200 Connection established
<
  ... every byte after this line is relayed untouched ...
Illustrative exchange — the TLS handshake begins on the next byte, between your client and the origin

That distinction decides how much of the standard comparison survives. Because essentially all traffic is HTTPS now, the HTTP proxy you are actually using is the tunnel, not the forwarding proxy — which means the caching, the header rewriting and the content filtering that most HTTP-versus-SOCKS5 articles credit to the HTTP side simply do not apply to the connection you will really open. Those are real capabilities of a forwarding proxy carrying cleartext, and they are unreachable on a tunnel by construction.

One name, two behaviours: a forwarding HTTP proxy reads and can rewrite your request; a CONNECT tunnel reads a hostname and a port and then nothing else, ever. If you are comparing protocols in order to pick one, the tunnel is the thing to compare against SOCKS5. For the general question of what a proxy is and where one sits, start with what a proxy server is instead.

The SOCKS5 Handshake, Byte by Byte

SOCKS5, defined in RFC 1928, never learns what protocol it is carrying. The exchange opens with a greeting: the client sends a version byte, a count of authentication methods it supports, and the method codes themselves. The server answers with two bytes — the version, and the one method it has chosen. If it answers 0xFF, no method was acceptable and the client must close the connection.

The client then sends a request naming a command: 0x01 CONNECT for an outbound TCP connection, 0x02 BIND for an inbound one, or 0x03 UDP ASSOCIATE. The same request carries an address-type byte — ATYP — which may be 0x01 for a four-octet IPv4 address, 0x03 for a domain name whose first octet is its length, or 0x04 for a sixteen-octet IPv6 address. The server replies, and from that reply onward the connection is raw bytes in both directions.

The same two messages as SOCKS5 sends them
> 05 02 00 02              VER=5, 2 methods offered: none, user/pass
< 05 02                    server chose 02 (username/password)

> 05 01 00 03 0b 65 78 61  VER=5, CMD=01 CONNECT, RSV=00,
  6d 70 6c 65 2e 63 6f 6d  ATYP=03 domain, LEN=11 "example.com"
  01 bb                    port 443
< 05 00 00 01 ...          REP=00 succeeded, then raw bytes
Illustrative bytes — RFC 1928 request layout, with the RFC 1929 subnegotiation omitted for clarity

That protocol-agnosticism is the whole of the SOCKS5 advantage, and it is a real one. Nothing in the exchange above mentions HTTP, so the same endpoint carries an SSH session, an SMTP conversation, a game client or an in-house binary protocol that an HTTP proxy would have no vocabulary for. Where an HTTP proxy needs a request it can parse or a CONNECT it can honour, SOCKS5 needs an address and a port.

The third command, UDP ASSOCIATE, is the one exception to “raw TCP bytes”, and RFC 1928 leaves parts of it optional — an implementation that does not support fragmentation must simply drop the datagrams it cannot handle. Whether a given server implements the command at all is not something a specification can tell you, so the proxy checker is the place to settle it against a specific endpoint. It stays out of this page beyond this sentence.

The two handshakes, on one time scale Both panels are drawn to the same vertical scale, so the cost of a protocol is visible as height rather than asserted in prose. Grey, dashed messages are the ones that only happen when credentials are demanded.
HTTP CONNECT RFC 9110
HTTP CONNECT handshake sequence CLIENT PROXY ORIGIN CONNECT example.com:443 HTTP/1.1 the request-target is a host and port, not a URL — so an HTTP proxy always resolves the name itself 407 Proxy Authentication Required Proxy-Authorization: Basic … only when credentials are demanded — one extra round trip HTTP/1.1 200 Connection established blind relay — TLS runs end to end through here TLS handshake, then encrypted payload the proxy copies bytes both ways and can read none of them

1 round trip before the first payload byte — 2 when a 407 challenge has to be answered.

SOCKS5 RFC 1928 · RFC 1929
SOCKS5 handshake sequence CLIENT PROXY ORIGIN 05 | NMETHODS | 00,02 greeting: version 5, and the methods offered 05 02 the server picks one — 00 none, 02 username/password 01 | ULEN | user | PLEN | pass 01 00 RFC 1929 subnegotiation — only if method 02 was chosen 05 01 00 ATYP … ATYP 01 — four resolved octets: your resolver answered ATYP 03 — the domain name itself: the proxy resolves it 05 00 00 … REP 00 succeeded blind relay — the proxy never learns what it carries your protocol, whatever it is

2 round trips before the first payload byte — 3 when username/password authentication is negotiated.

Footnote: CMD 0x03 UDP ASSOCIATE is the branch that leaves this diagram entirely — it sets up a separate datagram relay rather than a TCP stream, and RFC 1928 makes parts of it optional, so whether a given server answers it is a question for the proxy checker, not for a specification.

The Same Two Exchanges in Words

HTTP CONNECT

  1. Client to proxy: CONNECT example.com:443

    The request-target is an authority — a host and a port — rather than a URL with a path. The name is handed to the proxy by construction, so the proxy is the side that resolves it.

  2. Optionally, proxy to client: 407, then client to proxy: Proxy-Authorization

    A proxy that demands credentials answers with a challenge and the client retries carrying them. This costs one extra round trip unless the client sends them pre-emptively.

  3. Proxy to client: HTTP/1.1 200 Connection established

    The tunnel exists from this line onward. The proxy stops being a party to the conversation.

  4. Client to origin, through the proxy: TLS, then payload

    Bytes are relayed unchanged in both directions. The proxy has your hostname and port and nothing else.

SOCKS5

  1. Client to proxy: version 5 and a list of methods

    A greeting naming every authentication method the client is willing to use, most commonly 0x00 none and 0x02 username/password.

  2. Proxy to client: the method it selected

    Two bytes. A reply of 0xFF means nothing offered was acceptable and the client must close the connection.

  3. Optionally, the RFC 1929 subnegotiation

    If username/password was selected, the client sends its credentials and the server answers with a status byte. One more round trip.

  4. Client to proxy: the request, with its ATYP byte

    The command, then an address type: 0x01 carries four already-resolved octets, 0x03 carries the domain name itself. This single byte is the socks5 and socks5h fork.

  5. Proxy to client: the reply, then raw bytes

    A reply code of 0x00 means succeeded. Everything after it is your protocol, unexamined.

Who Turns the Hostname Into an IP Address

The socks5-versus-socks5h question has no HTTP equivalent at all, and that asymmetry is the sharpest genuine difference between the two protocols. An HTTP proxy is handed a hostname by construction: CONNECT's request-target is an authority, and a forwarding request line is an absolute URI. Either way the proxy receives a name and has to resolve it before it can open anything. There is no version of an HTTP proxy exchange in which the client has already done the lookup and passes an address instead.

SOCKS5 is the only one of the two that offers the choice, and it offers it as a single byte rather than as a setting. ATYP 0x01 says the four octets that follow are an address the client has already resolved. ATYP 0x03 says the bytes that follow are a name and the proxy should resolve it. Most client libraries default to resolving locally, which is why the choice usually has to be made deliberately.

What that actually changes is whose resolver answers, and resolvers do not all answer the same. A CDN steers you toward an edge near whoever asked; a split-horizon setup can return an entirely different record depending on where the query came from. Resolve locally and you get the answer for your own location while your traffic exits somewhere else, which is how a request ends up at an edge node that does not match its exit IP. Resolve at the proxy and the answer lines up with the exit. It also changes what your own network can observe, since a locally resolved name is a lookup your network sees regardless of where the traffic goes afterwards.

This section is about which byte carries the address and whose resolver answers it. For the scheme to actually type into a client, see setting up mobile proxies or the Linux configuration guide; to see what a specific proxy is really doing with your lookups, run it through the proxy checker.

One more consequence hides in the same byte. ATYP 0x04 carries a sixteen-octet IPv6 address, so a SOCKS5 client that has resolved locally to an IPv6 record can hand it straight over — a detail that matters if you are working with IPv6 mobile proxies and want to know which side of the connection chose the address family.

Authentication, and the Hop Neither Protocol Encrypts

The two protocols authenticate on completely different mechanics. An HTTP proxy that wants credentials answers an unauthenticated attempt with 407 Proxy Authentication Required and a Proxy-Authenticate header describing the challenge; the client retries with a Proxy-Authorization header. It is a rejection followed by a retry, which is why it costs a round trip unless the client volunteers credentials up front.

SOCKS5 never rejects and retries. The method is negotiated before anything else happens: the client lists what it supports, the server names one, and if that method is 0x02 the two sides run the RFC 1929 subnegotiation — a version byte of 0x01, then a username length and username, then a password length and password, each between one and 255 octets, answered with a two-byte status in which 0x00 means success. RFC 1928 also defines 0x01 for GSSAPI, specified separately in RFC 1961, though it is rarely what a commercial proxy offers.

Different mechanics, identical security position: neither protocol encrypts the hop between you and the proxy. RFC 1929 says so about its own method in as many words, warning that because the request carries the password in cleartext, the subnegotiation is not recommended for environments where sniffing is possible and practical. HTTP is no better — Proxy-Authorization with the Basic scheme is base64, which is an encoding chosen for transport safety, not a cipher, and is trivially reversible by anything on the path.

Choosing SOCKS5 for privacy reasons is choosing nothing. Whatever confidentiality you have on either protocol comes from the TLS session running end to end inside the tunnel, which the proxy cannot read either way. If the concern is specifically that your credentials travel in the clear, the answer is not a different proxy protocol — it is authenticating by IP allowlist instead of by password wherever your client has a fixed address.

This is also the cleanest way to see why the protocol question and the privacy question are not the same question. If what you actually want to know is what a proxy hides and from whom, and how that differs from a tunnel that encrypts the first hop by design, that comparison lives on proxy versus VPN rather than here.

Speed: What Is Measurable and What Is Folklore

The usual claim is that SOCKS5 is faster because it does not parse your traffic. It does not survive contact with the handshake. Both protocols stop parsing at exactly the same moment — the instant setup completes — and after that both are blind relays moving identical bytes over the same TCP connection to the same origin. There is no per-byte processing difference to measure, because there is no per-byte processing on either side.

On setup latency the ranking is the opposite of the folklore. HTTP CONNECT costs one round trip before your first payload byte: send CONNECT, receive 200. SOCKS5 costs two: greet, receive the method, send the request, receive the reply. Add username/password authentication and SOCKS5 costs three, while HTTP costs two only if the client waits to be challenged rather than sending credentials pre-emptively. That arithmetic is ours rather than the RFCs', but it follows directly from the message counts each specification requires.

Which means the variables that actually decide your throughput are the ones neither protocol controls: the route between the proxy and the origin, the exit network's conditions — radio quality and peering on a mobile exit, congestion on any exit — and how well your client reuses connections. On a long-lived session the setup cost is paid once and is statistical noise. On a scraping workload that opens a fresh connection per request, per-connection cost dominates everything, and the fix is connection reuse rather than a different protocol.

A benchmark that opens a new connection for every request is measuring handshakes, not throughput — and it will report whichever protocol has the shorter setup as the faster one, which tells you nothing about how either performs while carrying data. Measure a sustained transfer if you want a throughput number, and measure connection setup separately if that is what you care about.

For what genuinely moves the number on a collection workload — concurrency per host, retry behaviour, and the shape of the requests themselves — the Python 数据抓取指南 is the more useful page than any protocol comparison.

Which One Your Client Actually Wants

Protocol choice is decided by two things: what your traffic actually is, and what your client configures without help. It is not decided by a general verdict, because for the most common case there is no meaningful difference to decide on.

属性 Forwarding HTTP proxy HTTP CONNECT tunnel SOCKS5
What the proxy can read The whole request: method, path, headers, body The host and port in the CONNECT line, nothing after The address and port in the request, nothing after
Setup exchange None — the first request is the request CONNECT, then a 2xx response Greeting, method selection, request, reply
Round trips before the first payload byte 0 — the request itself is the first payload 1, or 2 when a 407 is answered 2, or 3 with username/password
Address form, and who resolves Absolute URI — the proxy resolves Host and port authority — the proxy resolves ATYP 0x01 IPv4, 0x03 name, 0x04 IPv6 — the client chooses
Transport carried TCP, and only HTTP over it TCP, any protocol inside the tunnel TCP, plus UDP where the server implements UDP ASSOCIATE
Credentials 407 challenge, then Proxy-Authorization 407 challenge, then Proxy-Authorization Negotiated method code, then the RFC 1929 subnegotiation
What the proxy may add or strip Via, X-Forwarded-For, header rewriting, caching, filtering Nothing at all once the tunnel is open Nothing at all once the reply is sent
Conventional port 3128 or 8080 by convention 3128 or 8080 by convention 1080 by convention
Client support without a helper Universal, but only reachable on cleartext HTTP Browsers, curl and every HTTP client library Browsers and curl natively; some libraries need an extra package

Read down the last two columns and the honest conclusion is that for HTTPS traffic they are the same product. If your traffic is HTTPS from a browser, a scraping framework or an HTTP library, both tunnel it identically, and the right choice is whichever one your tool configures natively.

When SOCKS5 Is the Answer

  • The traffic is not HTTP at all — SSH, SMTP, a database client, a game client, or an in-house binary protocol. A CONNECT tunnel can technically carry any of these, but only if the client knows how to ask for one, and most non-HTTP clients do not.
  • You want a single system-wide entry point that everything on the machine can be pointed at, rather than per-application HTTP proxy settings that many applications quietly ignore.
  • You need proxy-side name resolution from a client that only offers it on the SOCKS path, which is a common shape — the setting exists on the SOCKS side and has no HTTP counterpart to toggle.
  • You need UDP relay, which no HTTP proxy offers. Whether a specific SOCKS5 server implements it is a separate question, and one only a live test answers.

Outside those cases, the cheaper or simpler option is genuinely fine, and picking the one your client already supports costs you nothing measurable. PXM2 ships both, on separate ports, so the choice stays a client-side one rather than a purchase decision. If you are still deciding between proxy categories rather than protocols — which is a different question with real cost consequences — start from the types of proxies explained or the proxy types hub.

Deploy HTTP and SOCKS5 Mobile Proxies

Every PXM2 mobile proxy provides both HTTP and SOCKS5 endpoints on dedicated ports:

🇫🇷

法国

3 名操作员 20-150 Mbps
从……开始
$4.34 1小时时长
4G 5G
可用运算符:
Orange Bouygues SFR
🇸🇬

新加坡

2 名操作员 30-70 Mbps
从……开始
$2.99 1小时时长
4G
可用运算符:
Vivifi Singtel
🇮🇳

印度

3 名操作员 20-30 Mbps
从……开始
$2.74 1小时时长
4G
可用运算符:
Airtel Jio Vodafone Idea (Vi)
查看所有地点 →

常见问题解答

What is the crucial difference between SOCKS5 and SOCKS5h?

The sole difference is where domain name DNS resolution occurs. Standard SOCKS5 (socks5://) resolves the target hostname locally on the client machine before sending the target IP to the proxy, leaking your DNS queries to your local ISP. SOCKS5h (socks5h://) instructs the client application to skip local DNS resolution and send the raw domain name string directly to the proxy (using RFC 1928 address type 0x03), preventing DNS leaks.

Can an HTTP proxy handle UDP traffic like WebRTC or DNS?

No. HTTP proxies (including HTTPS CONNECT tunnels) are strictly limited to stream-oriented TCP connections. SOCKS5 explicitly supports UDP datagram forwarding through the UDP ASSOCIATE command (command byte 0x03), making it suitable for protocols that rely on UDP, such as WebRTC, online gaming, and real-time media.

Does SOCKS5 encrypt your internet connection?

No. SOCKS5 is a proxy transport protocol, not an encryption tunnel. While SOCKS5 tunnels your data neutrally without inspecting it, the connection between your computer and the SOCKS5 proxy server is unencrypted by default. If you transmit HTTPS traffic over SOCKS5, your data is encrypted by TLS; but plain HTTP or FTP traffic over SOCKS5 can be inspected by anyone on the local network.

Is SOCKS5 faster than an HTTP proxy for web scraping?

SOCKS5 exhibits marginally lower CPU overhead on the proxy server because it performs lightweight binary socket switching without parsing HTTP headers. However, in modern web scraping, HTTPS CONNECT proxies offer virtually identical throughput once the TCP connection is established and often integrate better with HTTP client connection pools (keep-alive) and browser automation tools.

How do I configure cURL to use SOCKS5 with remote DNS resolution?

In cURL, use the --socks5-hostname flag (or the socks5h:// URL prefix): curl --socks5-hostname user:pass@proxy_host:port https://ipinfo.io. This guarantees that cURL transmits the hostname “ipinfo.io” to the proxy rather than querying your local DNS resolver.

Proxy fundamentals

核心移动代理指南

One Proxy, Both Protocols

Dedicated 4G/5G mobile proxies with unlimited bandwidth — configure whichever protocol your client speaks and change your mind whenever you like.

获取移动代理