📄 tcpsock.h
字号:
/******************************************************************** * File: TcpSock.h * * Description: * * 1、封装TCP函数头文件 * * Functions: * * int nTcpServer(int nPort) * * int nTcpClose(int nSock) * * int nTcpAccept(int nSock, char *pCltIp) * * int nTcpSend(int nSock, const char *pBuf, int nLength) * * int nTcpRecv(int nSock, char *pBuf, int nLength, * * int nTimeout) * ******************************************************************** * Modify Log * * Date Author Description * * 2002-11-14 tangwn * ********************************************************************/#ifndef _TCPSOCK_H#define _TCPSOCK_H#define DefBackLog 10/******************************************************************** * Function: nTcpServer * * Description: * * 1、创建TCP服务器 * * 2、配置SOCKET属性 * * Input Param: * * 无 * * Output Param: * * 无 * * Return: * * >0 socket句柄 * * <=0 错误 * ********************************************************************/int nTcpServer(int nPort);/******************************************************************** * Function: nTcpConnect * * Description: * * 1、连接TCP服务器 * * Input Param: * * const char *pServIp * * int nPort * * Output Param: * * 无 * * Return: * * >0 socket句柄 * * <=0 错误 * ********************************************************************/int nTcpConnect(const char *pServIp, int nPort);/******************************************************************** * Function: nTcpClose * * Description: * * 1、关闭连接 * * Input Param: * * int nSock * * Output Param: * * 无 * * Return: * * >=0 成功 * * <0 错误 * ********************************************************************/int nTcpClose(int nSock);/******************************************************************** * Function: nTcpAccept * * Description: * * 1、接收连接 * * Input Param: * * char *pCltIp * * Output Param: * * char *pCltIp * * Return: * * >0 socket句柄 * * <=0 错误 * ********************************************************************/int nTcpAccept(int nSock, char *pCltIp);/******************************************************************** * Function: nTcpSend * * Description: * * 1、发送数据 * * Input Param: * * int nSock * * const char *pBuf * * int nLength * * Output Param: * * 无 * * Return: * * >=0 发送的数据数目 * * < 错误 * ********************************************************************/int nTcpSend(int nSock, const char *pBuf, int nLength);/******************************************************************** * Function: nTcpRecv * * Description: * * 1、接收数据 * * Input Param: * * int nSock * * char *pBuf * * int nLength * * Output Param: * * char *pBuf * * Return: * * >=0 接收的数据数目 * * < 错误 * ********************************************************************/int nTcpRecv(int nSock, char *pBuf, int nLength, int nTimeout);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -