2013-04-16 23:59:01 -04:00
|
|
|
#include <test.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2013-04-16 23:58:56 -04:00
|
|
|
#include <toku_assert.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
|
2013-04-16 23:59:01 -04:00
|
|
|
int usleep_socket(SOCKET s, unsigned int useconds) {
|
2013-04-16 23:57:27 -04:00
|
|
|
fd_set dummy;
|
|
|
|
struct timeval tv;
|
|
|
|
FD_ZERO(&dummy);
|
|
|
|
FD_SET(s, &dummy);
|
|
|
|
tv.tv_sec = useconds / 1000000;
|
|
|
|
tv.tv_usec = useconds % 1000000;
|
|
|
|
return select(0, 0, 0, &dummy, &tv);
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:53 -04:00
|
|
|
int verbose;
|
|
|
|
|
2013-04-16 23:59:01 -04:00
|
|
|
int test_main(int argc, char *const argv[]) {
|
2013-04-16 23:57:27 -04:00
|
|
|
int i;
|
|
|
|
int n = 1;
|
|
|
|
WSADATA wsadata;
|
|
|
|
SOCKET s;
|
|
|
|
|
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
char *arg = argv[i];
|
|
|
|
if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0)
|
|
|
|
verbose++;
|
|
|
|
n = atoi(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
WSAStartup(MAKEWORD(1, 0), &wsadata);
|
|
|
|
s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
2013-04-16 23:58:59 -04:00
|
|
|
printf("s=%"PRIu64"\n", s);
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
for (i=0; i<1000; i++) {
|
|
|
|
if (verbose) {
|
|
|
|
printf("usleep %d\n", i); fflush(stdout);
|
|
|
|
}
|
2013-04-16 23:59:01 -04:00
|
|
|
usleep_socket(s, n);
|
2013-04-16 23:57:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|