⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpclient.h

📁 该程序可以发送邮件。在一个文件中指定邮件的服务器IP地址和发件人的邮箱以及密码。
💻 H
字号:
/** * Written by Chen Yunfei, 10617136 * This is a class header to pack the procedure of the client use with TCP protocol * You can improve it to work for you */#ifndef _TCPCLIENT_H#define _TCPCLIENT_H#include<sys/socket.h>#include<netinet/in.h>#include<arpa/inet.h>#include<netdb.h>#include"XHeader.h"#define PORT 1500#define HOSTNAME "127.0.0.1"#define MAX_SIZE 8192class TcpClient{private: int Socket_descriptor; int Port; struct sockaddr_in Pin; struct hostent *Server_host_name; char Buf[BUFSIZE];public: TcpClient();                         //construct the TcpClient TcpClient(int port);                 //construct the TcpClient with port TcpClient(char* hostname,int port);  //construct the TcpClient with IP and port int InitTcpClient();                 //init it, in fact, the Socket_descriptor int Connect();                       //try to connect the server int Send(T* buf);                    //send Msg with Socket_descriptor int Recv(T* buf);                    //receive Msg with Socket_descriptor int Recvc(T* ch); void Close();                        //close the Socket_descriptor int getSockfd() const;               //get the value of the Socket_descriptor int getPort() const;                 //get the port to connect};#endif

⌨️ 快捷键说明

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