2 * PROJECT: ws2_32.dll API tests
3 * LICENSE: GPLv2 or any later version
4 * FILE: apitests/ws2_32/helpers.c
5 * PURPOSE: Helper functions for the socket tests
6 * COPYRIGHT: Copyright 2008 Colin Finck <mail@colinfinck.de>
10 #include <wine/test.h>
13 int CreateSocket(SOCKET
* psck
)
15 /* Create the socket */
16 *psck
= socket(AF_INET
, SOCK_STREAM
, IPPROTO_TCP
);
17 ok(*psck
!= INVALID_SOCKET
, "*psck = %d\n", *psck
);
19 if(*psck
== INVALID_SOCKET
)
21 printf("Winsock error code is %u\n", WSAGetLastError());
29 int ConnectToReactOSWebsite(SOCKET sck
)
33 struct sockaddr_in sa
;
35 /* Connect to "www.reactos.org" */
36 host
= gethostbyname("www.reactos.org");
38 sa
.sin_family
= AF_INET
;
39 sa
.sin_addr
.s_addr
= *(u_long
*)host
->h_addr_list
[0];
40 sa
.sin_port
= htons(80);
42 SCKTEST(connect(sck
, (struct sockaddr
*)&sa
, sizeof(sa
)));
47 int GetRequestAndWait(SOCKET sck
)
49 const char szGetRequest
[] = "GET / HTTP/1.0\r\n\r\n";
51 struct fd_set readable
;
53 /* Send the GET request */
54 SCKTEST(send(sck
, szGetRequest
, strlen(szGetRequest
), 0));
55 ok(iResult
== strlen(szGetRequest
), "iResult = %d\n", iResult
);
57 /* Shutdown the SEND connection */
58 SCKTEST(shutdown(sck
, SD_SEND
));
60 /* Wait until we're ready to read */
62 FD_SET(sck
, &readable
);
64 SCKTEST(select(0, &readable
, NULL
, NULL
, NULL
));