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

📄 client.h

📁 java socket server,对初学者很好的参考意义
💻 H
字号:
/*   a C++ socket server class    Keith Vertanen 11/98 */#define BUFFSIZE 64000#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <sys/types.h>#include <netinet/in.h>#include <netdb.h>#include <sys/socket.h>#include <sys/wait.h>class Client{  // class attibutes  public:		int port;	// the port I'm listening on	int dataport;	// port I listen for datagrams on (can be same or different from port)	int REVERSE;	  protected:			int new_fd;	               // new connection on new_fd	int datasockfd;	             	int senddatasockfd;	                      struct sockaddr_in their_addr; // connector's address information        struct sockaddr_in my_addr;    // my address information	struct hostent *he;	double buffer[BUFFSIZE];	// reuse the same memory for buffer	double buffer2[BUFFSIZE];  // class methods  public:	Client(int, int, char *host, int);		// constructor	void closesocket();		                // close the socket	void send_string(char *str);		        // send a string to socket	void send_ints(int *vals, int len);	        // send some integers	void send_bytes(char *vals, int len);           // send some bytes	void send_floats(float *vals, int len);		// send some floats	void send_doubles(double *vals, int len);	// send some doubles	void send_datagram(char *vals, int len);        // send a datagram	int recv_string(char *str, int max, char term); // recv a string	int recv_ints(int *vals, int max);  		// recv ints	int recv_floats(float *vals, int max);  	// recv floats	int recv_doubles(double *vals, int max);  	// recv doubles	int recv_bytes(char *vals, int max);  		// recv bytes	int recv_datagram(char *vals, int len);        // recv a datagram	private:	void recv_ack();	void send_ack();};

⌨️ 快捷键说明

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