Anorov/PySocks

socket.socket.recv vs. socks.socksocket.recv w/o proxy

totifra opened this issue · 0 comments

Hi there,

while monkeypatching a 3rd-party module, I observed a different behavior when calling socket.socket.recv(0) and socks.socksocket.recv(0). The former call will return b'' but the latter one will just stuck and never return.

The following code snippet reproduces this issue for me:

import socket
import socks

addr = ("127.0.0.1", 80)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(addr)
r = s.recv(0)
print(r)

s1 = socks.socksocket(socket.AF_INET, socket.SOCK_STREAM)
s1.connect(addr)
r1 = s1.recv(0)  # never returns!
print(r1)

I would have expected similar behavior at least when no proxy is used. But I also do not understand what the idea of a recv(0) is, since I have no experience using sockets. So maybe this is as expected?!

(Python 3.9.12, PySocks 1.7.1)

Thanks in advance
Thomas