You are assuming that the socket and the console are immediately writeable, so your program can get blocked if that is ever not the case. I'd use the "write" set of fds in the select
call to test the waters, my answer my answer over here has a bit of example code.
This can also be used to connect asynchronously -- you'd wait for the socket fd to become writeable, then you know that the connection is established. If the connection fails, the fd becomes readable, and you get an error for actually trying to read.
You are assuming that the socket and the console are immediately writeable, so your program can get blocked if that is ever not the case. I'd use the "write" set of fds in the select
call to test the waters, my answer over here has a bit of example code.
This can also be used to connect asynchronously -- you'd wait for the socket fd to become writeable, then you know that the connection is established. If the connection fails, the fd becomes readable, and you get an error for actually trying to read.
You are assuming that the socket and the console are immediately writeable, so your program can get blocked if that is ever not the case. I'd use the "write" set of fds in the select
call to test the waters, my answer over here has a bit of example code.
This can also be used to connect asynchronously -- you'd wait for the socket fd to become writeable, then you know that the connection is established. If the connection fails, the fd becomes readable, and you get an error for actually trying to read.
You are assuming that the socket and the console are immediately writeable, so your program can get blocked if that is ever not the case. I'd use the "write" set of fds in the select
call to test the waters, my answer over here has a bit of example code.
This can also be used to connect asynchronously -- you'd wait for the socket fd to become writeable, then you know that the connection is established. If the connection fails, the fd becomes readable, and you get an error for actually trying to read.