apache / apache/nuttx

non-blocking socket select

Open
#10,932 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

Hello everyone, I have noticed an issue while using socket for multiplexing. I wrote a server program based on non-blocking sockets and select. However, when I tried to connect to the server using a telnet client, I found that the connection was immediately closed. To investigate this matter, I examined the provided example `poll_main.c` from the system. I discovered that the example, when using select on non-blocking sockets, can successfully send and receive data with telnet without experiencing immediate disconnection. Upon careful examination of the code in the example, I noticed a difference compared to my implementation. In my code, I first called select to listen for the socket file descriptor and then used accept to accept the incoming connection request. However, in the system's example, they first called accept to handle a connection request and then used select to listen. I would like to know if it is necessary to follow the example's approach when using select in the system. Is it also possible, similar to standard Linux behavior, to use select first and then accept? In my implementation where select is called before accept, the telnet client returns 'connection closed by foreign host' when the connection is terminated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.