oosocket.h

来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C头文件 代码 · 共 404 行 · 第 1/2 页

H
404
字号
 * must be called after done with sockets. * * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */EXTERN int ooSocketsCleanup (void);/** * This function places a socket a state where it is listening for an incoming * connection. To accept connections, a socket is first created with the * ::rtSocketCreate function and bound to a local address with the * ::rtSocketBind function, a maxConnection for incoming connections is * specified with ::rtSocketListen, and then the connections are accepted with * the ::rtSocketAccept function. See description of 'listen' socket function * for further details. * * @param socket        The socket's handle created by call to *                      ::rtSocketCreate function. * @param maxConnection Maximum length of the queue of pending connections. * @return              Completion status of operation: 0 (ASN_OK) = *                      success, negative return value is error. */EXTERN int ooSocketListen (OOSOCKET socket, int maxConnection);/** * This function is used to peek at the received data without actually removing * it from the receive socket buffer. A receive call after this will get the * same data from the socket. * @param socket       The socket's handle created by call to ::rtSocketCreate *                     or ::rtSocketAccept function. * @param pbuf         Pointer to the buffer for the incoming data. * @param bufsize      Length of the buffer. * @return             If no error occurs, returns the number of bytes *                     received. Otherwise, the negative value is error code. */EXTERN int ooSocketRecvPeek   (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize);/** * This function receives data from a connected socket. It is used to read * incoming data on sockets. The socket must be connected before calling this * function. See description of 'recv' socket function for further details. * * @param socket       The socket's handle created by call to ::rtSocketCreate *                     or ::rtSocketAccept function. * @param pbuf         Pointer to the buffer for the incoming data. * @param bufsize      Length of the buffer. * @return             If no error occurs, returns the number of bytes *                     received. Otherwise, the negative value is error code. */EXTERN int ooSocketRecv (OOSOCKET socket, ASN1OCTET* pbuf,                            ASN1UINT bufsize);/** * This function receives data from a connected/unconnected socket. It is used * to read incoming data on sockets. It populates the remotehost and  * remoteport parameters with information of remote host. See description of  * 'recvfrom' socket function for further details. * * @param socket       The socket's handle created by call to ooSocketCreate *                      * @param pbuf         Pointer to the buffer for the incoming data. * @param bufsize      Length of the buffer. * @param remotehost   Pointer to a buffer in which remote ip address *                     will be returned. * @param hostBufLen   Length of the buffer passed for remote ip address. * @param remoteport   Pointer to an int in which remote port number *                     will be returned. * * @return             If no error occurs, returns the number of bytes *                     received. Otherwise, negative value. */EXTERN int ooSocketRecvFrom (OOSOCKET socket, ASN1OCTET* pbuf,			     ASN1UINT bufsize, char * remotehost,                              ASN1UINT hostBufLen, int * remoteport);/** * This function sends data on a connected socket. It is used to write outgoing * data on a connected socket. See description of 'send' socket function for * further details. * * @param socket       The socket's handle created by call to ::rtSocketCreate *                     or ::rtSocketAccept function. * @param pdata        Buffer containing the data to be transmitted. * @param size         Length of the data in pdata. * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */EXTERN int ooSocketSend (OOSOCKET socket, const ASN1OCTET* pdata,                            ASN1UINT size);/** * This function sends data on a connected or unconnected socket. See  * description of 'sendto' socket function for further details. * * @param socket       The socket's handle created by call to ::rtSocketCreate *                       or ::rtSocketAccept function. * @param pdata        Buffer containing the data to be transmitted. * @param size         Length of the data in pdata. * @param remotehost   Remote host ip address to which data has to  *                     be sent. * @param remoteport   Remote port ip address to which data has to  *                     be sent. * * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */EXTERN int ooSocketSendTo(OOSOCKET socket, const ASN1OCTET* pdata,                             ASN1UINT size, const char* remotehost,                            int remoteport);/** * This function is used for synchronous monitoring of multiple sockets. * For more information refer to documnetation of "select" system call.  * * @param nfds         The highest numbered descriptor to be monitored  *                     plus one. * @param readfds      The descriptors listed in readfds will be watched for  *                     whether read would block on them. * @param writefds     The descriptors listed in writefds will be watched for *                     whether write would block on them. * @param exceptfds    The descriptors listed in exceptfds will be watched for *                     exceptions. * @param timeout      Upper bound on amout of time elapsed before select  *                     returns.  * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */                                                       EXTERN int ooSocketSelect(int nfds, fd_set *readfds, fd_set *writefds,                             fd_set *exceptfds, struct timeval * timeout);/** * This function converts the string with IP address to a double word * representation. The converted address may be used with the ::rtSocketBind * function. * * @param pIPAddrStr   The null-terminated string with the IP address in the *                     following format: "NNN.NNN.NNN.NNN", where NNN is a *                     number in the range (0..255). * @param pIPAddr      Pointer to the converted IP address. * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */EXTERN int ooSocketStrToAddr (const char* pIPAddrStr, OOIPADDR* pIPAddr);/** * This function converts an internet dotted ip address to network address * * @param inetIp       The null-terminated string with the IP address in the *                     following format: "NNN.NNN.NNN.NNN", where NNN is a *                     number in the range (0..255). * @param netIp        Buffer in which the converted address will be returned. * @return             Completion status of operation: 0 (ASN_OK) = success, *                     negative return value is error. */EXTERN int ooSocketConvertIpToNwAddr(char *inetIp, char *netIp);/** * This function retrives the IP address of the local host. * * @param pIPAddrs   Pointer to a char buffer in which local IP address will be *                   returned. * @return           Completion status of operation: 0 (ASN_OK) = success, *                   negative return value is error. */EXTERN int ooGetLocalIPAddress(char * pIPAddrs);EXTERN int ooSocketGetSockName(OOSOCKET socket, struct sockaddr_in *name,                                                       int *size);EXTERN long ooSocketHTONL(long val);EXTERN short ooSocketHTONS(short val);/** * This function is used to retrieve the ip and port number used by the socket * passed as parameter. It internally uses getsockname system call for this  * purpose. * @param socket  Socket for which ip and port has to be determined. * @param ip      Buffer in which ip address will be returned. * @param len     Length of the ip address buffer. * @param port    Pointer to integer in which port number will be returned. * * @return        ASN_OK, on success; -ve on failed. */EXTERN int ooSocketGetIpAndPort(OOSOCKET socket, char *ip, int len, int *port);EXTERN int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList);/**  * @}  */#ifdef __cplusplus}#endif#endif /* _OOSOCKET_H_ */

⌨️ 快捷键说明

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