Skip to content

Instantly share code, notes, and snippets.

@uhmseohun
Created May 28, 2021 06:05
Show Gist options
  • Save uhmseohun/f8ef59504b2e7a24c80f15e64e869d71 to your computer and use it in GitHub Desktop.
Save uhmseohun/f8ef59504b2e7a24c80f15e64e869d71 to your computer and use it in GitHub Desktop.
socket_select_function
socket1 = Socket()
socket2 = Socket()
FD_ZERO(&read);
while (1) {
FD_SET(socket1, &read);
FD_SET(socket2, &read);
state = select(maxfd+1, &read, 0, 0, 0);
switch (state) {
case -1:
break;
case 0:
break;
default:
if(FD_ISSET(socket1, &read)) {
}
if (FD_ISSET(socket2, &read)) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment