UDP客户端
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <arpa/inet.h> #include <ctype.h> #include <time.h> #include <string> #define SERV_PORT 8000 char *randstr(char *str, const int len) { srand(time(NULL)); int i; for (i = 0; i < len; ++i) { switch ((rand() % 3)) { case 1: str[i] = 'A' + rand() % 26; break; case 2: str[i] = 'a' + rand() % 26; break; default: str[i] = '0' + rand() % 10; break; } } str[++i] = '