17 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include <config.h> |
21 |
|
|
22 |
#include <assert.h> |
#include <assert.h> |
23 |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
24 |
#include <string.h> |
#include <string.h> |
25 |
|
|
26 |
#include <arpa/inet.h> |
#include "http-server.h" |
|
#include <netinet/in.h> |
|
|
#include <netdb.h> |
|
|
#include <sys/socket.h> |
|
|
#include <unistd.h> |
|
|
|
|
27 |
#include "util.h" |
#include "util.h" |
28 |
|
|
29 |
int main(int argc, char ** argv) { |
int main(int argc, char ** argv) { |
30 |
|
#ifdef __MINGW32__ |
31 |
|
WSADATA data; |
32 |
|
if (WSAStartup(MAKEWORD(1, 1), &data) != 0) { |
33 |
|
return 1; |
34 |
|
} |
35 |
|
#endif |
36 |
|
|
37 |
int result; |
int result; |
38 |
|
|
39 |
if (argc < 3) { |
if (argc < 3) { |
49 |
a.sin_port = htons(connect_port); |
a.sin_port = htons(connect_port); |
50 |
a.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
a.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
51 |
|
|
52 |
int s = socket(PF_INET, SOCK_STREAM, 0); |
SOCKET s = socket(PF_INET, SOCK_STREAM, 0); |
53 |
assert(s > 0); |
assert(s != INVALID_SOCKET); |
54 |
|
|
55 |
result = connect(s, (struct sockaddr *) &a, sizeof(a)); |
result = connect(s, (struct sockaddr *) &a, sizeof(a)); |
56 |
assert(result == 0); |
assert(result == 0); |
72 |
} |
} |
73 |
} |
} |
74 |
|
|
75 |
close(s); |
closesocket(s); |
76 |
return 0; |
return 0; |
77 |
} |
} |