oosocket.h
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C头文件 代码 · 共 404 行 · 第 1/2 页
H
404 行
/* * Copyright (C) 1997-2005 by Objective Systems, Inc. * * This software is furnished under an open source license and may be * used and copied only in accordance with the terms of this license. * The text of the license may generally be found in the root * directory of this installation in the COPYING file. It * can also be viewed online at the following URL: * * http://www.obj-sys.com/open/license.html * * Any redistributions of this file including modified versions must * maintain this copyright notice. * *****************************************************************************//** * @file ooSocket.h * Common runtime constants, data structure definitions, and run-time functions * to support the sockets' operations. */#ifndef _OOSOCKET_H_#define _OOSOCKET_H_#ifdef _WIN32_WCE#include <winsock.h>#elif defined(_WIN32) || defined(_WIN64)#include <sys/types.h>#define INCL_WINSOCK_API_TYPEDEFS 1#define INCL_WINSOCK_API_PROTOTYPES 0#include <winsock2.h>#else#include <sys/types.h>#include "sys/time.h"#include <sys/socket.h>#include <sys/ioctl.h>#include <netinet/in.h>#include <netdb.h>#include <unistd.h>#include <arpa/inet.h>#include <net/if.h>#endif#include "ooasn1.h"#ifdef __cplusplusextern "C" {#endif#ifndef EXTERN#ifdef MAKE_DLL#define EXTERN __declspec(dllexport)#elif defined (USEASN1DLL)#define EXTERN __declspec(dllimport)#else#define EXTERN#endif /* MAKE_DLL */#endif /* EXTERN *//** * @defgroup sockets Socket Layer * @{ */#if defined (_WIN64)typedef unsigned __int64 OOSOCKET; /**< Socket's handle */#elif defined (_WIN32)typedef unsigned int OOSOCKET; /**< Socket's handle */#elsetypedef int OOSOCKET; /**< Socket's handle */#endif#define OOSOCKET_INVALID ((OOSOCKET)-1)/** * The IP address represented as unsigned long value. The most significant 8 * bits in this unsigned long value represent the first number of the IP * address. The least significant 8 bits represent the last number of the IP * address. */typedef unsigned long OOIPADDR;#define OOIPADDR_ANY ((OOIPADDR)0)#define OOIPADDR_LOCAL ((OOIPADDR)0x7f000001UL) /* 127.0.0.1 */typedef struct OOInterface{ char *name; char *addr; char *mask; struct OOInterface *next;}OOInterface;/** * This function permits an incoming connection attempt on a socket. It * extracts the first connection on the queue of pending connections on socket. * It then creates a new socket and returns a handle to the new socket. The * newly created socket is the socket that will handle the actual connection * and has the same properties as original socket. See description of 'accept' * socket function for further details. * * @param socket The socket's handle created by call to ::rtSocketCreate * function. * @param pNewSocket The pointer to variable to receive the new socket's * handle. * @param destAddr Optional pointer to a buffer that receives the IP * address of the connecting entity. It may be NULL. * @param destPort Optional pointer to a buffer that receives the port of * the connecting entity. It may be NULL. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketAccept (OOSOCKET socket, OOSOCKET *pNewSocket, OOIPADDR* destAddr, int* destPort);/** * This function converts an IP address to its string representation. * * @param ipAddr The IP address to be converted. * @param pbuf Pointer to the buffer to receive a string with the IP * address. * @param bufsize Size of the buffer. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketAddrToStr (OOIPADDR ipAddr, char* pbuf, int bufsize);/** * This function associates a local address with a socket. It is used on an * unconnected socket before subsequent calls to the ::rtSocketConnect or * ::rtSocketListen functions. See description of 'bind' socket function for * further details. * * @param socket The socket's handle created by call to ::rtSocketCreate * function. * @param addr The local IP address to assign to the socket. * @param port The local port number to assign to the socket. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port);/** * This function closes an existing socket. * * @param socket The socket's handle created by call to ::rtSocketCreate * or ::rtSocketAccept function. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketClose (OOSOCKET socket);/** * This function establishes a connection to a specified socket. It is used to * create a connection to the specified destination. When the socket call * completes successfully, the socket is ready to send and receive data. See * description of 'connect' socket function for further details. * * @param socket The socket's handle created by call to ::rtSocketCreate * function. * @param host 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 port The destination port to connect. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketConnect (OOSOCKET socket, const char* host, int port);/** * This function creates a socket. The only streaming TCP/IP sockets are * supported at the moment. * * @param psocket The pointer to the socket's handle variable to receive * the handle of new socket. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketCreate (OOSOCKET* psocket);/** * This function creates a UDP datagram socket. * * @param psocket The pointer to the socket's handle variable to receive * the handle of new socket. * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketCreateUDP (OOSOCKET* psocket);/** * This function initiates use of sockets by an application. This function must * be called first before use sockets. * * @return Completion status of operation: 0 (ASN_OK) = success, * negative return value is error. */EXTERN int ooSocketsInit (void);/** * This function terminates use of sockets by an application. This function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?