tcpclient.h
来自「该程序可以发送邮件。在一个文件中指定邮件的服务器IP地址和发件人的邮箱以及密码。」· C头文件 代码 · 共 45 行
H
45 行
/** * 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 + =
减小字号Ctrl + -
显示快捷键?