?? tcpclient.h
字號(hào):
/** * 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
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -