| 8 | static bool __server_fixed = true; |
| 9 | |
| 10 | static void run(void) |
| 11 | { |
| 12 | acl::socket_stream stream; |
| 13 | char* buf; |
| 14 | |
| 15 | // ���ص�ַ |
| 16 | if (stream.bind_udp(__local_addr) == false) |
| 17 | { |
| 18 | printf("bind addr %s error %s\r\n", |
| 19 | __server_addr, acl::last_serror()); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | // ����Զ�̷����ַ |
| 24 | else |
| 25 | stream.set_peer(__server_addr); |
| 26 | |
| 27 | stream.set_rw_timeout(1); |
| 28 | |
| 29 | // �����ڴ� |
| 30 | buf = (char*) malloc(__dat_length + 1); |
| 31 | memset(buf, 'X', __dat_length); |
| 32 | buf[__dat_length] = 0; |
| 33 | |
| 34 | char res[4096]; |
| 35 | |
| 36 | struct timeval begin; |
| 37 | gettimeofday(&begin, NULL); |
| 38 | |
| 39 | int i = 0, ret; |
| 40 | for (; i < __max_count; i++) |
| 41 | { |
| 42 | // ����˿��ܻ��ñ�ĵ�ַ�ظ����ݣ�������Ҫ��������Զ�̷����ַ |
| 43 | if (!__server_fixed) |
| 44 | stream.set_peer(__server_addr); |
| 45 | |
| 46 | // �������� |
| 47 | if (stream.write(buf, __dat_length) == -1) |
| 48 | { |
| 49 | printf("write error %s\r\n", acl::last_serror()); |
| 50 | break; |
| 51 | } |
| 52 | |
| 53 | // �������� |
| 54 | else if ((ret = stream.read(res, sizeof(res) - 1, false)) == -1) |
| 55 | { |
| 56 | printf("read error %s\r\n", acl::last_serror()); |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | if (i % 1000 == 0) |
| 61 | { |
| 62 | res[ret] = 0; |
| 63 | printf("read >>> %s\r\n", res); |
| 64 | } |
| 65 | |
| 66 | if (i % 1000 == 0) |
| 67 | { |
no test coverage detected