ReactOS  0.4.13-dev-52-g0efcfec
ws2_32.h File Reference
#include <ntstatus.h>
#include <stdio.h>
#include <apitest.h>
#include <ws2tcpip.h>
#include <ndk/rtlfuncs.h>
#include <ndk/mmfuncs.h>
Include dependency graph for ws2_32.h:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define SCKTEST(_cmd_)
 

Functions

int CreateSocket (SOCKET *sck)
 
int ConnectToReactOSWebsite (SOCKET sck)
 
int GetRequestAndWait (SOCKET sck)
 

Variables

HANDLE g_hHeap
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 16 of file ws2_32.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 17 of file ws2_32.h.

◆ SCKTEST

#define SCKTEST (   _cmd_)
Value:
iResult = _cmd_; \
ok(iResult != SOCKET_ERROR, "iResult = %d\n", iResult); \
if(iResult == SOCKET_ERROR) \
{ \
printf("Winsock error code is %u\n", WSAGetLastError()); \
closesocket(sck); \
WSACleanup(); \
return 0; \
}
#define SOCKET_ERROR
Definition: winsock.h:333
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112

Definition at line 25 of file ws2_32.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 15 of file ws2_32.h.

Function Documentation

◆ ConnectToReactOSWebsite()

int ConnectToReactOSWebsite ( SOCKET  sck)

Definition at line 27 of file helpers.c.

28 {
29  int iResult;
30  struct hostent* host;
31  struct sockaddr_in sa;
32 
33  /* Connect to "www.reactos.org" */
34  host = gethostbyname("test.winehq.org");
35 
36  sa.sin_family = AF_INET;
37  sa.sin_addr.s_addr = *(u_long*)host->h_addr_list[0];
38  sa.sin_port = htons(80);
39 
40  SCKTEST(connect(sck, (struct sockaddr *)&sa, sizeof(sa)));
41 
42  return 1;
43 }
unsigned long u_long
Definition: linux.h:269
#define SCKTEST(_cmd_)
Definition: ws2_32.h:25
char * host
Definition: whois.c:55
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
#define AF_INET
Definition: tcpip.h:117
#define htons(x)
Definition: module.h:213
static struct sockaddr_in sa
Definition: adnsresfilter.c:69

Referenced by Test_ioctlsocket(), Test_recv(), and Test_WSARecv().

◆ CreateSocket()

int CreateSocket ( SOCKET sck)

Definition at line 11 of file helpers.c.

12 {
13  /* Create the socket */
15  ok(*psck != INVALID_SOCKET, "*psck = %d\n", *psck);
16 
17  if(*psck == INVALID_SOCKET)
18  {
19  printf("Winsock error code is %u\n", WSAGetLastError());
20  WSACleanup();
21  return 0;
22  }
23 
24  return 1;
25 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define ok(value,...)
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define INVALID_SOCKET
Definition: winsock.h:332
#define AF_INET
Definition: tcpip.h:117
#define SOCK_STREAM
Definition: tcpip.h:118
#define printf
Definition: config.h:203

◆ GetRequestAndWait()

int GetRequestAndWait ( SOCKET  sck)

Definition at line 45 of file helpers.c.

46 {
47  const char szGetRequest[] = "GET / HTTP/1.0\r\n\r\n";
48  int iResult;
49  struct fd_set readable;
50 
51  /* Send the GET request */
52  SCKTEST(send(sck, szGetRequest, strlen(szGetRequest), 0));
53  ok(iResult == strlen(szGetRequest), "iResult = %d\n", iResult);
54 #if 0 /* breaks windows too */
55  /* Shutdown the SEND connection */
56  SCKTEST(shutdown(sck, SD_SEND));
57 #endif
58  /* Wait until we're ready to read */
59  FD_ZERO(&readable);
60  FD_SET(sck, &readable);
61 
62  SCKTEST(select(0, &readable, NULL, NULL, NULL));
63 
64  return 1;
65 }
Definition: winsock.h:66
#define SCKTEST(_cmd_)
Definition: ws2_32.h:25
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
#define SD_SEND
Definition: winsock.h:55

Referenced by Test_ioctlsocket(), and Test_recv().

Variable Documentation

◆ g_hHeap

HANDLE g_hHeap

Definition at line 52 of file globals.c.

Referenced by MemAlloc(), MemFree(), and MemInit().