⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prio.h

📁 Netscape NSPR库源码
💻 H
📖 第 1 页 / 共 5 页
字号:
 * INPUTS: *     PRFileDesc *fd *       Points to a PRFileDesc object representing a socket that will be *       used to listen for new connections. *     PRIntn backlog *       Specifies the maximum length of the queue of pending connections. * OUTPUTS: *     None * RETURN: PRStatus *     Upon successful completion of listen request, PR_Listen *     returns PR_SUCCESS.  Otherwise, it returns PR_FAILURE.  Further *     failure information can be obtained by calling PR_GetError(). ************************************************************************** */NSPR_API(PRStatus) PR_Listen(PRFileDesc *fd, PRIntn backlog);/* ************************************************************************* * FUNCTION: PR_Shutdown * DESCRIPTION: *    Shut down part of a full-duplex connection on a socket. * INPUTS: *     PRFileDesc *fd *       Points to a PRFileDesc object representing a connected socket. *     PRIntn how *       Specifies the kind of disallowed operations on the socket. *           PR_SHUTDOWN_RCV - Further receives will be disallowed *           PR_SHUTDOWN_SEND - Further sends will be disallowed *           PR_SHUTDOWN_BOTH - Further sends and receives will be disallowed * OUTPUTS: *     None * RETURN: PRStatus *     Upon successful completion of shutdown request, PR_Shutdown *     returns PR_SUCCESS.  Otherwise, it returns PR_FAILURE.  Further *     failure information can be obtained by calling PR_GetError(). ************************************************************************** */typedef enum PRShutdownHow{    PR_SHUTDOWN_RCV = 0,      /* disallow further receives */    PR_SHUTDOWN_SEND = 1,     /* disallow further sends */    PR_SHUTDOWN_BOTH = 2      /* disallow further receives and sends */} PRShutdownHow;NSPR_API(PRStatus)    PR_Shutdown(PRFileDesc *fd, PRShutdownHow how);/* ************************************************************************* * FUNCTION: PR_Recv * DESCRIPTION: *    Receive a specified number of bytes from a connected socket. *     The operation will block until some positive number of bytes are  *     transferred, a time out has occurred, or there is an error.  *     No more than 'amount' bytes will be transferred. * INPUTS: *     PRFileDesc *fd *       points to a PRFileDesc object representing a socket. *     void *buf *       pointer to a buffer to hold the data received. *     PRInt32 amount *       the size of 'buf' (in bytes) *     PRIntn flags *       must be zero or PR_MSG_PEEK. *     PRIntervalTime timeout *       Time limit for completion of the receive operation. * OUTPUTS: *     None * RETURN: PRInt32 *         a positive number indicates the number of bytes actually received. *         0 means the network connection is closed. *         -1 indicates a failure. The reason for the failure is obtained *         by calling PR_GetError(). ************************************************************************** */#define PR_MSG_PEEK 0x2NSPR_API(PRInt32)    PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount,                PRIntn flags, PRIntervalTime timeout);/* ************************************************************************* * FUNCTION: PR_Send * DESCRIPTION: *    Send a specified number of bytes from a connected socket. *     The operation will block until all bytes are  *     processed, a time out has occurred, or there is an error.  * INPUTS: *     PRFileDesc *fd *       points to a PRFileDesc object representing a socket. *     void *buf *       pointer to a buffer from where the data is sent. *     PRInt32 amount *       the size of 'buf' (in bytes) *     PRIntn flags *        (OBSOLETE - must always be zero) *     PRIntervalTime timeout *       Time limit for completion of the send operation. * OUTPUTS: *     None * RETURN: PRInt32 *     A positive number indicates the number of bytes successfully processed. *     This number must always equal 'amount'. A -1 is an indication that the *     operation failed. The reason for the failure is obtained by calling *     PR_GetError(). ************************************************************************** */NSPR_API(PRInt32)    PR_Send(PRFileDesc *fd, const void *buf, PRInt32 amount,                                PRIntn flags, PRIntervalTime timeout);/* ************************************************************************* * FUNCTION: PR_RecvFrom * DESCRIPTION: *     Receive up to a specified number of bytes from socket which may *     or may not be connected. *     The operation will block until one or more bytes are  *     transferred, a time out has occurred, or there is an error.  *     No more than 'amount' bytes will be transferred. * INPUTS: *     PRFileDesc *fd *       points to a PRFileDesc object representing a socket. *     void *buf *       pointer to a buffer to hold the data received. *     PRInt32 amount *       the size of 'buf' (in bytes) *     PRIntn flags *        (OBSOLETE - must always be zero) *     PRNetAddr *addr *       Specifies the address of the sending peer. It may be NULL. *     PRIntervalTime timeout *       Time limit for completion of the receive operation. * OUTPUTS: *     None * RETURN: PRInt32 *         a positive number indicates the number of bytes actually received. *         0 means the network connection is closed. *         -1 indicates a failure. The reason for the failure is obtained *         by calling PR_GetError(). ************************************************************************** */NSPR_API(PRInt32) PR_RecvFrom(    PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,    PRNetAddr *addr, PRIntervalTime timeout);/* ************************************************************************* * FUNCTION: PR_SendTo * DESCRIPTION: *    Send a specified number of bytes from an unconnected socket. *    The operation will block until all bytes are  *    sent, a time out has occurred, or there is an error.  * INPUTS: *     PRFileDesc *fd *       points to a PRFileDesc object representing an unconnected socket. *     void *buf *       pointer to a buffer from where the data is sent. *     PRInt32 amount *       the size of 'buf' (in bytes) *     PRIntn flags *        (OBSOLETE - must always be zero) *     PRNetAddr *addr *       Specifies the address of the peer..*     PRIntervalTime timeout *       Time limit for completion of the send operation. * OUTPUTS: *     None * RETURN: PRInt32 *     A positive number indicates the number of bytes successfully sent. *     -1 indicates a failure. The reason for the failure is obtained *     by calling PR_GetError(). ************************************************************************** */NSPR_API(PRInt32) PR_SendTo(    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,    const PRNetAddr *addr, PRIntervalTime timeout);/**************************************************************************** FUNCTION: PR_TransmitFile** DESCRIPTION:**    Transmitfile sends a complete file (sourceFile) across a socket **    (networkSocket).  If headers is non-NULL, the headers will be sent across**    the socket prior to sending the file.** **    Optionally, the PR_TRANSMITFILE_CLOSE_SOCKET flag may be passed to**    transmitfile.  This flag specifies that transmitfile should close the**    socket after sending the data.**** INPUTS:**    PRFileDesc *networkSocket**        The socket to send data over**    PRFileDesc *sourceFile**        The file to send**    const void *headers**        A pointer to headers to be sent before sending data**    PRInt32       hlen**        length of header buffers in bytes.**    PRTransmitFileFlags       flags**        If the flags indicate that the connection should be closed,**        it will be done immediately after transferring the file, unless**        the operation is unsuccessful. .*     PRIntervalTime timeout *        Time limit for completion of the transmit operation.**** RETURNS:**    Returns the number of bytes written or -1 if the operation failed.**    If an error occurs while sending the file, the PR_TRANSMITFILE_CLOSE_**    SOCKET flag is ignored. The reason for the failure is obtained**    by calling PR_GetError().***************************************************************************/NSPR_API(PRInt32) PR_TransmitFile(    PRFileDesc *networkSocket, PRFileDesc *sourceFile,    const void *headers, PRInt32 hlen, PRTransmitFileFlags flags,    PRIntervalTime timeout);/**************************************************************************** FUNCTION: PR_SendFile** DESCRIPTION:**    PR_SendFile sends data from a file (sendData->fd) across a socket **    (networkSocket).  If specified, a header and/or trailer buffer are sent**	  before and after the file, respectively. The file offset, number of bytes** 	  of file data to send, the header and trailer buffers are specified in the**	  sendData argument.** **    Optionally, if the PR_TRANSMITFILE_CLOSE_SOCKET flag is passed, the**    socket is closed after successfully sending the data.**** INPUTS:**    PRFileDesc *networkSocket**        The socket to send data over**    PRSendFileData *sendData**        Contains the FD, file offset and length, header and trailer**		  buffer specifications.**    PRTransmitFileFlags       flags**        If the flags indicate that the connection should be closed,**        it will be done immediately after transferring the file, unless**        the operation is unsuccessful. .*     PRIntervalTime timeout *        Time limit for completion of the send operation.**** RETURNS:**    Returns the number of bytes written or -1 if the operation failed.**    If an error occurs while sending the file, the PR_TRANSMITFILE_CLOSE_**    SOCKET flag is ignored. The reason for the failure is obtained**    by calling PR_GetError().***************************************************************************/struct PRSendFileData {	PRFileDesc	*fd;			/* file to send							*/	PRUint32	file_offset;	/* file offset							*/	PRSize		file_nbytes;	/* number of bytes of file data to send	*/								/* if 0, send data from file_offset to	*/								/* end-of-file.							*/	const void	*header;		/* header buffer						*/	PRInt32		hlen;			/* header len							*/	const void	*trailer;		/* trailer buffer						*/	PRInt32		tlen;			/* trailer len							*/};NSPR_API(PRInt32) PR_SendFile(    PRFileDesc *networkSocket, PRSendFileData *sendData,	PRTransmitFileFlags flags, PRIntervalTime timeout);/**************************************************************************** FUNCTION: PR_AcceptRead** DESCRIPTION:**    AcceptRead accepts a new connection, returns the newly created**    socket's descriptor and also returns the connecting peer's address.**    AcceptRead, as its name suggests, also receives the first block of data **    sent by the peer.**** INPUTS:**    PRFileDesc *listenSock**        A socket descriptor that has been called with the PR_Listen() **        function, also known as the rendezvous socket.**    void *buf**        A pointer to a buffer to receive data sent by the client.  This **        buffer must be large enough to receive <amount> bytes of data**        and two PRNetAddr structures, plus an extra 32 bytes. See:**        PR_ACCEPT_READ_BUF_OVERHEAD.**    PRInt32 amount**        The number of bytes of client data to receive.  Does not include**        the size of the PRNetAddr structures.  If 0, no data will be read**        from the client.**    PRIntervalTime timeout**        The timeout interval only applies to the read portion of the **        operation.  PR_AcceptRead will block indefinitely until the **        connection is accepted; the read will timeout after the timeout **        interval elapses.** OUTPUTS:**    PRFileDesc **acceptedSock**        The file descriptor for the newly connected socket.  This parameter**        will only be valid if the function return does not indicate failure.**    PRNetAddr  **peerAddr,**        The address of the remote socket.  This parameter will only be**        valid if the function return does not indicate failure.  The**        returned address is not guaranteed to be properly aligned.** ** RETURNS:**     The number of bytes read from the client or -1 on failure.  The reason **     for the failure is obtained by calling PR_GetError().****************************************************************************/       /* define buffer overhead constant. Add this value to the user's ** data length when allocating a buffer to accept data.**    Example:**    #define USER_DATA_SIZE 10**    char buf[USER_DATA_SIZE + PR_ACCEPT_READ_BUF_OVERHEAD];**    bytesRead = PR_AcceptRead( s, fd, &a, &p, USER_DATA_SIZE, ...);*/#define PR_ACCEPT_READ_BUF_OVERHEAD (32+(2*sizeof(PRNetAddr)))NSPR_API(PRInt32) PR_AcceptRead(    PRFileDesc *listenSock, PRFileDesc **acceptedSock,    PRNetAddr **peerAddr, void *buf, PRInt32 amount, PRIntervalTime timeout);/**************************************************************************** FUNCTION: PR_NewTCPSocketPair** DESCRIPTION:**    Create a new TCP socket pair. The returned descriptors can be used**    interchangeably; they are interconnected f

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -