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 |
|
|
|
#include <netinet/in.h> |
|
|
#include <sys/socket.h> |
|
|
#include <unistd.h> |
|
|
|
|
26 |
#include "http-server.h" |
#include "http-server.h" |
27 |
|
|
28 |
int main(void) { |
int main(void) { |
29 |
|
#ifdef __MINGW32__ |
30 |
|
WSADATA data; |
31 |
|
if (WSAStartup(MAKEWORD(1, 1), &data) != 0) { |
32 |
|
return 1; |
33 |
|
} |
34 |
|
#endif |
35 |
|
|
36 |
int result; |
int result; |
37 |
|
|
38 |
struct sockaddr_in a; |
struct sockaddr_in a; |
40 |
a.sin_port = htons(8000); |
a.sin_port = htons(8000); |
41 |
a.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
a.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
42 |
|
|
43 |
int s = socket(PF_INET, SOCK_STREAM, 0); |
SOCKET s = socket(PF_INET, SOCK_STREAM, 0); |
44 |
assert(s > 0); |
assert(s != INVALID_SOCKET); |
45 |
|
|
46 |
result = connect(s, (struct sockaddr *) &a, sizeof(a)); |
result = connect(s, (struct sockaddr *) &a, sizeof(a)); |
47 |
assert(result == 0); |
assert(result == 0); |
52 |
ssize_t bytes_sent = send(s, message, message_length, 0); |
ssize_t bytes_sent = send(s, message, message_length, 0); |
53 |
assert(bytes_sent == (ssize_t) message_length); |
assert(bytes_sent == (ssize_t) message_length); |
54 |
|
|
55 |
close(s); |
closesocket(s); |
56 |
return 0; |
return 0; |
57 |
} |
} |