Skip to content
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

Close sideband socket if there's a trigger #11

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amehra-ni
Copy link
Collaborator

We now have an extra parameter that tells whether to close the sideband socket or not.

As accept, is a blocking call, we can't just check the variable for the trigger, as it will remain blocked until a connection is established.
Hence, I've updated it to use select. The select function monitors multiple file descriptors to see if any of them are ready.
It returns the number of file descriptors that are ready for the requested I/O, or -1 if an error occurs.
If it's greater than 0, it means that one or more file descriptors are ready for reading. The code then checks if the sockfd file descriptor is ready using the FD_ISSET macro. If sockfd is ready, it indicates that there is an incoming connection and we do the remaining operation accordingly.

Tested it, when the boolean is set to true, the loop breaks and the socket closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant