代码拉取完成,页面将自动刷新
同步操作将从 eclipser/socket 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* File: Socket.h
* Author: Vicky.H
* Email: eclipser@163.com
*
* Created on 2014年2月25日, 上午11:34
*/
#ifndef CN_VICKY__SOCKET_H
#define CN_VICKY__SOCKET_H
#include "SocketAPI.h"
typedef unsigned long IP_t;
const int IP_SIZE = 24;
class Socket {
public:
// constructor
Socket();
Socket(const char* host, unsigned int port);
// destructor
virtual ~Socket();
public:
bool create();
// close connection
void close();
// try connect to remote host
bool connect();
bool connect(const char* host, unsigned int port);
// close previous connection and connect to another socket
bool reconnect(const char* host, unsigned int port);
// send data to peer
unsigned int send(const void* buf, unsigned int len, unsigned int flags = 0);
// receive data from peer
unsigned int receive(void* buf, unsigned int len, unsigned int flags = 0);
unsigned int available()const;
SOCKET accept(struct sockaddr* addr, unsigned int* addrlen);
bool bind();
bool bind(unsigned int port);
bool listen(int backlog);
public:
// get/set socket's linger status
unsigned int getLinger()const;
bool setLinger(unsigned int lingertime);
bool isReuseAddr()const;
bool setReuseAddr(bool on = true);
// get is Error
unsigned int getSockError()const;
// get/set socket's nonblocking status
bool isNonBlocking()const;
bool setNonBlocking(bool on = true);
// get/set receive buffer size
unsigned int getReceiveBufferSize()const;
bool setReceiveBufferSize(unsigned int size);
// get/set send buffer size
unsigned int getSendBufferSize()const;
bool setSendBufferSize(unsigned int size);
unsigned int getPort()const;
IP_t getHostIP()const;
// check if socket is valid
bool isValid()const;
// get socket descriptor
SOCKET getSOCKET()const;
bool isSockError()const;
public:
SOCKET m_SocketID;
// socket address structure
SOCKADDR_IN m_SockAddr;
// peer host
char m_Host[IP_SIZE];
// peer port
unsigned int m_Port;
};
#endif /* CN_VICKY__SOCKET_H */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。