-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read data from the server #57
Comments
Hi @RealYukiSan, To get this working, you'll have to make
|
Thanks @lealem47 for the help, I tried to print num_bytes, it seems work but the num_bytes never reach 0?
|
That means it never stops receiving data. Could be that the google server is sending you keep-alives |
I don't see keep-alive header in the response:
it seems to me like the response isn't finished yet, but it stuck after the last 5 bytes |
Can you share your code that's printing numBytes |
import wolfssl
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
secure_sock = wolfssl.wrap_socket(sock)
secure_sock.connect(("dns.google", 443))
secure_sock.write(b"GET / HTTP/1.1\r\nHost: dns.google\r\n\r\n")
response = bytearray(1024) # A mutable buffer for the recv_into method
data = b"" # To accumulate the received data
while True:
num_bytes = secure_sock.recv_into(response, 1024)
print(num_bytes)
if num_bytes == 0:
break # Stop if no more data is received
data += response[:num_bytes] # Accumulate the data read into 'data'
secure_sock.close() |
I've read in the docs that
recv_into
will return zero if there's no more received data, but the followingrecv_into
always immediately return 0 at the first call, I wondering is the way I code fundamentally wrong?The text was updated successfully, but these errors were encountered: