-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
TCP socket stream #29775
Comments
This is very typical in TCP, if the peer sends us things one byte a time then we receive each byte in separate TCP segment. We do not collect the packets anywhere in receive path so you will also receive things one byte a time. This is not a bug. |
But I tested on Linux under the same situation, and the result is that there is unnecessary to recv five times. |
Sure, but in Linux there is queueing in receive side which collects smaller packets into larger ones before giving them to the application. Zephyr does not do it currently because it requires memory and we try to limit the memory usage. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Describe the bug
I set up a client socket to communicate with the remote server, and the server send five 1 byte packets.
I want to recv 5 bytes at a time, but there is no way. I need to call recv 5 times to receive the packets.
To Reproduce
struct sockaddr_in info;
int sock, ret;
char buf[100];
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
memset(&info, 0, sizeof(info));
info.sin_family = PF_INET;
info.sin_addr.s_addr = inet_addr("192.168.127.5");
info.sin_port = htons(8700);
connect(sock, (struct sockaddr *)&info, sizeof(info));
k_sleep(K_SECONDS(10));
ret = recv(sock, buf, 5, 0);
printf("ret %d\n", ret);
The server transmits the five packets in 10 seconds, and then I start to receive.
But I found that I had to call recv 5 times to receive all the packets.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: