/* ノンブロックでrecvを行えるかチェックする */
int CheckReceivable( int fd )
{
fd_set fdset;
int re;
struct timeval timeout;FD_ZERO( &fdset );
FD_SET( fd , &fdset );/* timeoutは0秒。つまりselectはすぐ戻ってく る */
timeout.tv_sec = 0;
timeout.tv_usec = 0;/* readできるかチェック */
re = select( fd+1 , &fdset , NULL , NULL , &timeout );return (re == 1) ? TRUE : FALSE;
}
/* ノンブロックでsendを行えるかチェックする */
int CheckSendable( int fd )
{
fd_set fdset;
int re;
struct timeval timeout;FD_ZERO( &fdset );
FD_SET( fd , &fdset );/* timeoutは0秒。つまりselectはすぐ戻ってく る */
timeout.tv_sec = 0;
timeout.tv_usec = 0;/* writeできるかチェック */
re = select( fd+1 , NULL , &fdset , NULL , &timeout );return (re == 1) ? TRUE : FALSE;
}