📄 select.c
字号:
SEL_Setup_Recv_Ports(max_sockets, readfs, NU_NULL);
} /* while(1) */
/* Let others in while we are waiting for the connection. */
#ifdef PLUS
NU_Release_Semaphore(&TCP_Resource);
#else
NU_Release_Resource(TCP_Resource);
#endif
return return_status;
} /* end of NU_Select */
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_FD_Check */
/* */
/* DESCRIPTION */
/* */
/* This fuction will check to see if a particular bit has been set in a */
/* bit map. */
/* */
/* AUTHOR */
/* */
/* MQ Qian, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* */
/* CALLS */
/* */
/* No functions called by this function */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* MQ Qina 10/12/94 Initial version. */
/* MQ Qina 11/07/94 Last modification date */
/* */
/****************************************************************************/
INT NU_FD_Check(INT socket, FD_SET *fd)
{
if (fd->words[socket/FD_BITS] & (1<<(socket%FD_BITS)))
return(NU_TRUE);
else
return(NU_FALSE);
}
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_FD_Set */
/* */
/* DESCRIPTION */
/* */
/* Sets a bit in a bit map. */
/* */
/* AUTHOR */
/* */
/* MQ Qian, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* str_echo */
/* */
/* CALLS */
/* */
/* No functions called by this function */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* MQ Qina 10/12/94 Initial version. */
/* MQ Qina 11/07/94 Last modification date */
/* */
/****************************************************************************/
VOID NU_FD_Set(int16 socket, FD_SET *fd)
{
fd->words[socket/FD_BITS] |= (NU_TRUE<<(socket%FD_BITS));
}
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_FD_Init */
/* */
/* DESCRIPTION */
/* */
/* Sets all bits in a bit map to 0. */
/* */
/* AUTHOR */
/* */
/* MQ Qian, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* */
/* CALLS */
/* */
/* No functions called by this function */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* MQ Qina 10/12/94 Initial version. */
/* MQ Qina 11/07/94 Last modification date */
/* */
/****************************************************************************/
VOID NU_FD_Init(FD_SET *fd)
{
INT i;
for (i=0; i<FD_ELEMENTS; fd->words[i++]=0L);
}
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_FD_Reset */
/* */
/* DESCRIPTION */
/* */
/* Resets a bit in a bit map. */
/* */
/* AUTHOR */
/* */
/* MQ Qian, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* str_echo */
/* */
/* CALLS */
/* */
/* No functions called by this function */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* MQ Qina 10/12/94 Initial version. */
/* MQ Qina 11/07/94 Last modification date */
/* */
/****************************************************************************/
VOID NU_FD_Reset(INT socket, FD_SET *fd)
{
fd->words[socket/FD_BITS] &= ~(NU_TRUE<<(socket%FD_BITS));
}
/****************************************************************************/
/* FUNCTION */
/* */
/* SEL_Check_Recv */
/* */
/* DESCRIPTION */
/* */
/* Checks the sockets specified in a bitmap to see if any are data ready. */
/* If any are found to be data ready the bitmap is modified so that only */
/* the bits for the data ready sockets are set. Else the bitmap is */
/* untouched. */
/* */
/* AUTHOR */
/* */
/* Glen Johnson, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* NU_Select */
/* */
/* CALLS */
/* */
/* NU_FD_Init */
/* NU_FD_Check */
/* NU_FD_Reset */
/* NU_GetPnum */
/* NU_Get_UDP_Pnum */
/* makeuport */
/* */
/* INPUTS */
/* */
/* max_sockets The max number of sockets that can be open. */
/* readfs Bitmap of sockets to check for data. */
/* */
/* OUTPUTS */
/* */
/* NU_SUCCES if at least one socket is data ready, NU_NO_DATA otherwise*/
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 11/16/95 Initial version. */
/* */
/****************************************************************************/
STATUS SEL_Check_Recv(INT max_sockets, FD_SET *readfs)
{
INT i; /* Loop counter */
STATUS return_status = NU_NO_DATA; /* Assume failure, if a data ready
socket is found status will be updated
to success. */
FD_SET tmpfs;
struct sock_struct *sockptr; /* pointer to current socket */
int16 pnum; /* local machine's port number */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -