socket.h

来自「由一个古老的BASIC解释器改进而成, 保留了ANSI C固有的艺术美感.」· C头文件 代码 · 共 54 行

H
54
字号
// socket.h

#ifndef SOCKET_H_
#define SOCKET_H_

#include <string>
#include <stdexcept>

#ifdef __BORLANDC__
#pragma warn -8026
#endif

class SocketError : public std::exception {
public:
	SocketError (const std::string & nstr);
	SocketError (const std::string & nstr, int errnum);
	~SocketError () throw () { }
	const char * what () const throw ();
private:
	std::string str;
	static std::string strErr;
};

class Socket {
public:
	Socket ();
	Socket (const Socket & nsock);
	~Socket ();
	Socket & operator = (const Socket & nsock);
	//TypeSocket handle ();
	bool eof ();
	std::string readline ();
	int read (char * str, int len);
	void write (const std::string & str);
	void write (const char * str, size_t len);
protected:
	class Internal;
	Internal * in;
};

class TcpSocket : public Socket {
public:
	TcpSocket ();
};

class TcpSocketClient : public TcpSocket {
public:
	TcpSocketClient (const std::string & host, unsigned short port);
};

#endif

// End of socket.h

⌨️ 快捷键说明

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