基于linux或windows平台上的c/s简单通信
linux: tcpclient.cpp 1 #include<iostream> 2 #include<unistd.h> 3 #include<sys/types.h> 4 #include<sys/socket.h> 5 #include<netdb.h> 6 #include<arpa/inet.h> 7 #include<cstring> 8 #include<sstream> 9 10 using namespace std; 11 12 #define BUFSIZE 512 13 14 // #define SERVERIP "192.168.41.32" 15 // #define SERVERPORT 4140 16 17 /*error report*/ 18 static void bail(const char *on_what){ 19 fputs(strerror(errno), stderr); 20 fputs(": ", stderr); 21 fputs(on_what, stderr); 22 fputc('\n', stderr); 23 exit(1); 24 } 25 26 void getarg(int argc,char* argv[],const char** SERVERIP,int* SERVERPORT) 27 { 28