Hi everyone,
I am not sure if this is a bug or if I am just not doing something correctly.
I am hosting a HTTP Webserver and I use Recv to get the first 128 bytes, the HTTP request itself is about 500+ bytes but I don't need it. I find that if I do not set my buffer to 768bytes to receive the full packet my connection closes prematurely.
Is there a SOCKOPT i can set to overcome this issue or is my only option to expand the buffer and report this as a bug?
Thank you!!!
TCP Socket Closes due to Small buffer
-
- Posts: 8
- Joined: Fri Feb 17, 2017 6:23 pm
Re: TCP Socket Closes due to Small buffer
Hi everyone,
I just wanted to check in and see if there was any more additional information I could provide to help troubleshoot this issue?
I just wanted to check in and see if there was any more additional information I could provide to help troubleshoot this issue?
Re: TCP Socket Closes due to Small buffer
Hi;
I know that I am not really answering your question, but I always use 1024 bytes in the receiving buffer:
I know that I am not really answering your question, but I always use 1024 bytes in the receiving buffer:
Code: Select all
while True:
conn, addr = self.sock.accept()
raw = conn.recv(1024).decode('UTF-8')
if not raw:
print('Null Request.',addr)
self.close(conn)
else:
self.request(conn,raw)
-
- Posts: 8
- Joined: Fri Feb 17, 2017 6:23 pm
Re: TCP Socket Closes due to Small buffer
Thank you for the reply sir. The issue that I am having is that multiple requests are being generated by clients at the same time and its causing a large amount of time to elapse before it times out for the ESP to get to the next request, Now If I just check the first few bytes I can tell that the request is one that can be just discards or not however to make this work I just need to check the first few bytes, It seems that processing all 1024 of that just delays the whole process :-\devnull wrote:Hi;
I know that I am not really answering your question, but I always use 1024 bytes in the receiving buffer:
Code: Select all
while True: conn, addr = self.sock.accept() raw = conn.recv(1024).decode('UTF-8') if not raw: print('Null Request.',addr) self.close(conn) else: self.request(conn,raw)