ReactOS  r76032
sock.c File Reference
#include <ntstatus.h>
#include <wine/test.h>
#include <winsock2.h>
#include <wine/winternl.h>
#include <ws2tcpip.h>
#include <wsipx.h>
#include <wsnwlink.h>
#include <mswsock.h>
#include <mstcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
Include dependency graph for sock.c:

Go to the source code of this file.

Classes

struct  thread_info
 
struct  sock_info
 
struct  test_params
 
struct  server_params
 
struct  client_params
 
struct  test_setup
 
struct  server_memory
 
struct  client_memory
 
struct  select_thread_params
 
struct  addr_hint_tests
 
struct  async_message
 

Macros

#define _WIN32_WINNT   0x0600
 
#define WIN32_NO_STATUS
 
#define WSA_CMSG_ALIGN(len)   (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
 
#define MAX_CLIENTS   4 /* Max number of clients */
 
#define FIRST_CHAR   'A' /* First character in transferred pattern */
 
#define BIND_SLEEP   10 /* seconds to wait between attempts to bind() */
 
#define BIND_TRIES   6 /* Number of bind() attempts */
 
#define TEST_TIMEOUT
 
#define NUM_UDP_PEERS   3 /* Number of UDP sockets to create and test > 1 */
 
#define NUM_THREADS   3 /* Number of threads to run getservbyname */
 
#define NUM_QUERIES   250 /* Number of getservbyname queries per thread */
 
#define SERVERIP   "127.0.0.1" /* IP to bind to */
 
#define SERVERPORT   9374 /* Port number to bind to */
 
#define wsa_ok(op, cond, msg)
 
#define make_keepalive(k, enable, time, interval)
 
#define SOCKTIMEOUT1
 
#define SOCKTIMEOUT2   997000 /* 997 seconds */
 
#define IP_PKTINFO_LEN   (sizeof(WSACMSGHDR) + WSA_CMSG_ALIGN(sizeof(struct in_pktinfo)))
 
#define STD_STREAM_SOCKET
 
#define FD_ZERO_ALL()   { FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); }
 
#define FD_SET_ALL(s)   { FD_SET(s, &readfds); FD_SET(s, &writefds); FD_SET(s, &exceptfds); }
 
#define WM_SOCKET   (WM_USER+100)
 
#define ok_event_seq   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_event_sequence
 
#define POLL_CLEAR()   ix = 0
 
#define POLL_SET(s, ev)   {fds[ix].fd = s; fds[ix++].events = ev;}
 
#define POLL_ISSET(s, rev)   poll_isset(fds, ix, s, rev)
 
#define compare_file(h, s, o)   compare_file2(h,s,o,__FILE__,__LINE__)
 
#define WM_ASYNCCOMPLETE   (WM_USER + 100)
 

Typedefs

typedef struct thread_info thread_info
 
typedef struct sock_info sock_info
 
typedef struct test_params test_params
 
typedef struct server_params server_params
 
typedef struct client_params client_params
 
typedef struct test_setup test_setup
 
typedef struct server_memory server_memory
 
typedef struct client_memory client_memory
 
typedef struct select_thread_params select_thread_params
 
typedef struct async_message async_message
 

Functions

static void (WINAPI *pfreeaddrinfo)(struct addrinfo *)
 
static int (WINAPI *pgetaddrinfo)(LPCSTR
 
static PCSTR (WINAPI *pInetNtop)(INT
 
static PCWSTR (WINAPI *pInetNtopW)(INT
 
static NTSTATUS (WINAPI *pNtSetInformationFile)(HANDLE
 
static DWORD (WINAPI *pGetAdaptersInfo)(PIP_ADAPTER_INFO
 
static SOCKET setup_server_socket (struct sockaddr_in *addr, int *len)
 
static SOCKET setup_connector_socket (struct sockaddr_in *addr, int len, BOOL nonblock)
 
static int tcp_socketpair (SOCKET *src, SOCKET *dst)
 
static void set_so_opentype (BOOL overlapped)
 
static int set_blocking (SOCKET s, BOOL blocking)
 
static void fill_buffer (char *buf, int chunk_size, int n_chunks)
 
static int test_buffer (char *buf, int chunk_size, int n_chunks)
 
static void read_zero_bytes (SOCKET s)
 
static int do_synchronous_send (SOCKET s, char *buf, int buflen, int flags, int sendlen)
 
static int do_synchronous_recv (SOCKET s, char *buf, int buflen, int flags, int recvlen)
 
static int do_synchronous_recvfrom (SOCKET s, char *buf, int buflen, int flags, struct sockaddr *from, int *fromlen, int recvlen)
 
static void check_so_opentype (void)
 
static void compare_addrinfo (ADDRINFO *a, ADDRINFO *b)
 
static void compare_addrinfow (ADDRINFOW *a, ADDRINFOW *b)
 
static void do_bind (SOCKET s, struct sockaddr *addr, int addrlen)
 
static void server_start (server_params *par)
 
static void server_stop (void)
 
static void client_start (client_params *par)
 
static void client_stop (void)
 
static VOID WINAPI simple_server (server_params *par)
 
static VOID WINAPI oob_server (server_params *par)
 
static VOID WINAPI select_server (server_params *par)
 
static VOID WINAPI simple_client (client_params *par)
 
static VOID WINAPI oob_client (client_params *par)
 
static VOID WINAPI simple_mixed_client (client_params *par)
 
static void WINAPI event_client (client_params *par)
 
static void test_WithoutWSAStartup (void)
 
static void test_WithWSAStartup (void)
 
static void Init (void)
 
static void Exit (void)
 
static void StartServer (LPTHREAD_START_ROUTINE routine, test_params *general, server_params *par)
 
static void StartClients (LPTHREAD_START_ROUTINE routine, test_params *general, client_params *par)
 
static void do_test (test_setup *test)
 
static void test_set_getsockopt (void)
 
static void test_so_reuseaddr (void)
 
static void test_ip_pktinfo (void)
 
static void test_UDP (void)
 
static DWORD WINAPI do_getservbyname (void *param)
 
static void test_getservbyname (void)
 
static void test_WSASocket (void)
 
static void test_WSADuplicateSocket (void)
 
static void test_WSAEnumNetworkEvents (void)
 
static void test_WSAAddressToStringA (void)
 
static void test_WSAAddressToStringW (void)
 
static void test_WSAStringToAddressA (void)
 
static void test_WSAStringToAddressW (void)
 
static DWORD WINAPI SelectReadThread (void *param)
 
static DWORD WINAPI SelectCloseThread (void *param)
 
static void test_errors (void)
 
static void test_listen (void)
 
static void test_select (void)
 
static DWORD WINAPI AcceptKillThread (void *param)
 
static int CALLBACK AlwaysDeferConditionFunc (LPWSABUF lpCallerId, LPWSABUF lpCallerData, LPQOS pQos, LPQOS lpGQOS, LPWSABUF lpCalleeId, LPWSABUF lpCalleeData, GROUP *g, DWORD_PTR dwCallbackData)
 
static void test_accept (void)
 
static void test_extendedSocketOptions (void)
 
static void test_getsockname (void)
 
static void test_dns (void)
 
int WINAPI gethostname (char *name, int namelen)
 
static void test_gethostbyname (void)
 
static void test_gethostbyname_hack (void)
 
static void test_gethostname (void)
 
static void test_inet_addr (void)
 
static void test_addr_to_print (void)
 
static void test_inet_pton (void)
 
static void test_ioctlsocket (void)
 
static DWORD WINAPI drain_socket_thread (LPVOID arg)
 
static void test_send (void)
 
static LRESULT CALLBACK ws2_test_WndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void get_event_details (int event, int *bit, char *name)
 
static const chardbgstr_event_seq (const LPARAM *seq)
 
static chardbgstr_event_seq_result (SOCKET s, WSANETWORKEVENTS *netEvents)
 
static void flush_events (SOCKET s, HANDLE hEvent)
 
static int match_event_sequence (SOCKET s, WSANETWORKEVENTS *netEvents, const LPARAM *seq)
 
static void ok_event_sequence (SOCKET s, HANDLE hEvent, const LPARAM *seq, const LPARAM **broken_seqs, int completelyBroken)
 
static void test_events (int useMessages)
 
static void test_ipv6only (void)
 
static void test_WSASendMsg (void)
 
static void test_WSASendTo (void)
 
static DWORD WINAPI recv_thread (LPVOID arg)
 
static void WINAPI io_completion (DWORD error, DWORD transferred, WSAOVERLAPPED *overlapped, DWORD flags)
 
static void test_WSARecv (void)
 
static BOOL poll_isset (WSAPOLLFD *fds, int max, SOCKET s, int rev)
 
static void test_WSAPoll (void)
 
static void test_GetAddrInfoW (void)
 
static void test_GetAddrInfoExW (void)
 
static void verify_ipv6_addrinfo (ADDRINFOA *result, const char *expectedIp)
 
static void test_getaddrinfo (void)
 
static void test_ConnectEx (void)
 
static void test_AcceptEx (void)
 
static void test_DisconnectEx (void)
 
static void compare_file2 (HANDLE handle, SOCKET sock, int offset, const char *file, int line)
 
static void test_TransmitFile (void)
 
static void test_getpeername (void)
 
static void test_sioRoutingInterfaceQuery (void)
 
static void test_sioAddressListChange (void)
 
static void test_synchronous_WSAIoctl (void)
 
static HWND create_async_message_window (void)
 
static void wait_for_async_message (HWND hwnd, HANDLE handle)
 
static void test_WSAAsyncGetServByPort (void)
 
static void test_WSAAsyncGetServByName (void)
 
static SOCKET setup_iocp_src (struct sockaddr_in *bindAddress)
 
static void test_completion_port (void)
 
static void test_address_list_query (void)
 
static DWORD WINAPI inet_ntoa_thread_proc (void *param)
 
static void test_inet_ntoa (void)
 
static void test_WSALookupService (void)
 
static void test_WSAEnumNameSpaceProvidersA (void)
 
static void test_WSAEnumNameSpaceProvidersW (void)
 
 START_TEST (sock)
 

Variables

static LPCSTR
 
static LPCWSTR
 
static const ADDRINFOW
PADDRINFOW *static const WCHAR
servname
 
namespace GUIDnamespace_id
 
namespace GUID const ADDRINFOEXW * hints
 
namespace GUID const
ADDRINFOEXW ADDRINFOEXW ** 
result
 
namespace GUID const
ADDRINFOEXW ADDRINFOEXW struct
timeval
timeout
 
namespace GUID const
ADDRINFOEXW ADDRINFOEXW struct
timeval OVERLAPPED
overlapped
 
namespace GUID const
ADDRINFOEXW ADDRINFOEXW struct
timeval OVERLAPPED
LPLOOKUPSERVICE_COMPLETION_ROUTINE 
completion_routine
 
namespace GUID const
ADDRINFOEXW ADDRINFOEXW struct
timeval OVERLAPPED
LPLOOKUPSERVICE_COMPLETION_ROUTINE
HANDLE
handle
 
static LPVOID
 
static LPSTR
 
static ULONG
 
static LPWSTR
 
static DWORD
 
static LPHANDLE
 
static LPDWORD
 
static LPWSAQUERYSETW
 
static LPWSANAMESPACE_INFOA
 
static LPWSANAMESPACE_INFOW
 
static INT
 
static PIO_STATUS_BLOCK
 
static PVOID
 
static FILE_INFORMATION_CLASS
 
static PULONG
 
static BOOL
 
static const struct addr_hint_tests hinttests []
 
static DWORD tls
 
static HANDLE thread [1+MAX_CLIENTS]
 
static DWORD thread_id [1+MAX_CLIENTS]
 
static HANDLE server_ready
 
static HANDLE client_ready [MAX_CLIENTS]
 
static int client_id
 
static const LINGER linger_testvals []
 
static test_setup tests []
 
static BOOL drain_pause = FALSE
 
static struct async_messagemessages_received
 
static int completion_called
 

Macro Definition Documentation

#define _WIN32_WINNT   0x0600

Definition at line 24 of file sock.c.

#define BIND_SLEEP   10 /* seconds to wait between attempts to bind() */

Definition at line 45 of file sock.c.

Referenced by do_bind().

#define BIND_TRIES   6 /* Number of bind() attempts */

Definition at line 46 of file sock.c.

Referenced by do_bind().

#define compare_file (   h,
  s,
  o 
)    compare_file2(h,s,o,__FILE__,__LINE__)

Definition at line 8591 of file sock.c.

Referenced by test_TransmitFile().

#define FD_SET_ALL (   s)    { FD_SET(s, &readfds); FD_SET(s, &writefds); FD_SET(s, &exceptfds); }

Definition at line 3775 of file sock.c.

Referenced by test_select().

#define FD_ZERO_ALL ( )    { FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds); }

Definition at line 3774 of file sock.c.

Referenced by test_select().

#define FIRST_CHAR   'A' /* First character in transferred pattern */

Definition at line 44 of file sock.c.

Referenced by fill_buffer(), and test_buffer().

Definition at line 1946 of file sock.c.

Referenced by test_ip_pktinfo().

#define make_keepalive (   k,
  enable,
  time,
  interval 
)
Value:
k.onoff = enable; \
k.keepalivetime = time; \
k.keepaliveinterval = interval;
__u16 time
Definition: mkdosfs.c:366
GLboolean enable
Definition: glext.h:11120
int k
Definition: mpi.c:3369

Definition at line 66 of file sock.c.

Referenced by test_ioctlsocket().

#define MAX_CLIENTS   4 /* Max number of clients */
#define NUM_QUERIES   250 /* Number of getservbyname queries per thread */

Definition at line 53 of file sock.c.

Referenced by do_getservbyname().

#define NUM_THREADS   3 /* Number of threads to run getservbyname */

Definition at line 52 of file sock.c.

Referenced by test_getservbyname().

#define NUM_UDP_PEERS   3 /* Number of UDP sockets to create and test > 1 */

Definition at line 50 of file sock.c.

Referenced by test_UDP().

#define ok_event_seq   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_event_sequence

Definition at line 5747 of file sock.c.

Referenced by test_events().

#define POLL_CLEAR ( )    ix = 0

Definition at line 6900 of file sock.c.

Referenced by test_WSAPoll().

#define POLL_ISSET (   s,
  rev 
)    poll_isset(fds, ix, s, rev)

Definition at line 6902 of file sock.c.

Referenced by test_WSAPoll().

#define POLL_SET (   s,
  ev 
)    {fds[ix].fd = s; fds[ix++].events = ev;}

Definition at line 6901 of file sock.c.

Referenced by test_WSAPoll().

#define SERVERIP   "127.0.0.1" /* IP to bind to */

Definition at line 55 of file sock.c.

Referenced by SelectReadThread(), and test_UDP().

#define SERVERPORT   9374 /* Port number to bind to */
#define SOCKTIMEOUT1
Value:
63000 /* 63 seconds. Do not test fractional part because of a
bug in the linux kernel (fixed in 2.6.8) */

Definition at line 1347 of file sock.c.

Referenced by test_set_getsockopt().

#define SOCKTIMEOUT2   997000 /* 997 seconds */

Definition at line 1349 of file sock.c.

Referenced by test_set_getsockopt().

#define STD_STREAM_SOCKET
Value:
0, \
#define SERVERPORT
Definition: sock.c:56
#define SERVERIP
Definition: sock.c:55
#define SOCK_STREAM
Definition: tcpip.h:118

Definition at line 2129 of file sock.c.

#define TEST_TIMEOUT
Value:
30 /* seconds to wait before killing child threads
after server initialization, if something hangs */

Definition at line 47 of file sock.c.

Referenced by do_getservbyname(), do_test(), and test_getservbyname().

#define WIN32_NO_STATUS

Definition at line 27 of file sock.c.

#define WM_ASYNCCOMPLETE   (WM_USER + 100)
#define WM_SOCKET   (WM_USER+100)

Definition at line 5477 of file sock.c.

Referenced by test_events(), and ws2_test_WndProc().

#define WSA_CMSG_ALIGN (   len)    (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))

Definition at line 41 of file sock.c.

#define wsa_ok (   op,
  cond,
  msg 
)
Value:
do { \
int tmp, err = 0; \
tmp = op; \
if ( !(cond tmp) ) err = WSAGetLastError(); \
ok ( cond tmp, msg, GetCurrentThreadId(), err); \
} while (0);
UINT op
Definition: effect.c:219
int int int * err
Definition: fci.h:172
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:704
UINT msg
Definition: msvc.h:92
#define ok(value,...)
Definition: CImage.cpp:33
static int(WINAPI *pgetaddrinfo)(LPCSTR

Definition at line 58 of file sock.c.

Referenced by client_stop(), do_synchronous_recv(), do_synchronous_recvfrom(), do_synchronous_send(), event_client(), oob_client(), oob_server(), select_server(), SelectReadThread(), simple_client(), simple_mixed_client(), simple_server(), and test_AcceptEx().

Typedef Documentation

Function Documentation

static DWORD WINAPI AcceptKillThread ( void param)
static

Definition at line 4159 of file sock.c.

Referenced by test_accept().

4160 {
4161  select_thread_params *par = param;
4162  struct sockaddr_in address;
4163  int len = sizeof(address);
4164  SOCKET client_socket;
4165 
4167  client_socket = accept(par->s, (struct sockaddr*) &address, &len);
4168  if (client_socket != INVALID_SOCKET)
4169  closesocket(client_socket);
4170  par->ReadKilled = (client_socket == INVALID_SOCKET);
4171  return 0;
4172 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define closesocket
Definition: main.c:50
#define INVALID_SOCKET
Definition: winsock.h:332
GLfloat param
Definition: glext.h:5796
GLuint address
Definition: glext.h:9393
GLenum GLsizei len
Definition: glext.h:6722
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
UINT_PTR SOCKET
Definition: winsock.h:47
static HANDLE server_ready
Definition: sock.c:227
static int CALLBACK AlwaysDeferConditionFunc ( LPWSABUF  lpCallerId,
LPWSABUF  lpCallerData,
LPQOS  pQos,
LPQOS  lpGQOS,
LPWSABUF  lpCalleeId,
LPWSABUF  lpCalleeData,
GROUP g,
DWORD_PTR  dwCallbackData 
)
static

Definition at line 4175 of file sock.c.

Referenced by test_accept(), and test_AcceptEx().

4178 {
4179  return CF_DEFER;
4180 }
#define CF_DEFER
Definition: winsock2.h:415
static void check_so_opentype ( void  )
static

Definition at line 381 of file sock.c.

Referenced by oob_client(), simple_client(), and simple_mixed_client().

382 {
383  int tmp = 1, len;
384  len = sizeof (tmp);
386  ok ( tmp == 0, "check_so_opentype: wrong startup value of SO_OPENTYPE: %d\n", tmp );
387 }
#define SOL_SOCKET
Definition: winsock.h:398
#define INVALID_SOCKET
Definition: winsock.h:332
GLenum GLsizei len
Definition: glext.h:6722
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
#define SO_OPENTYPE
Definition: ws2_32.h:40
#define ok(value,...)
Definition: CImage.cpp:33
static void client_start ( client_params par)
static

Definition at line 511 of file sock.c.

Referenced by event_client(), oob_client(), simple_client(), and simple_mixed_client().

512 {
513  test_params *gen = par->general;
515 
516  TlsSetValue ( tls, mem );
517 
519 
520  mem->s = WSASocketA ( AF_INET, gen->sock_type, gen->sock_prot,
521  NULL, 0, par->sock_flags );
522 
523  mem->addr.sin_family = AF_INET;
524  mem->addr.sin_addr.s_addr = inet_addr ( gen->inet_addr );
525  mem->addr.sin_port = htons ( gen->inet_port );
526 
527  ok ( mem->s != INVALID_SOCKET, "Client: WSASocket failed\n" );
528 
529  mem->send_buf = LocalAlloc ( LPTR, 2 * gen->n_chunks * gen->chunk_size );
530  mem->recv_buf = mem->send_buf + gen->n_chunks * gen->chunk_size;
531  fill_buffer ( mem->send_buf, gen->chunk_size, gen->n_chunks );
532 
534  /* Wait for the other clients to come up */
536 }
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:143
char * recv_buf
Definition: sock.c:172
#define inet_addr(cp)
Definition: inet.h:98
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1221
SOCKET WSAAPI WSASocketA(IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, IN GROUP g, IN DWORD dwFlags)
Definition: socklife.c:444
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static int client_id
Definition: sock.c:229
int sock_prot
Definition: sock.c:124
smooth NULL
Definition: ftsmooth.c:557
int sock_type
Definition: sock.c:123
#define MAX_CLIENTS
Definition: sock.c:43
struct sockaddr_in addr
Definition: sock.c:170
#define INVALID_SOCKET
Definition: winsock.h:332
SOCKET s
Definition: sock.c:169
const char * inet_addr
Definition: sock.c:125
static void fill_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:306
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:228
short inet_port
Definition: sock.c:126
int n_clients
Definition: sock.c:129
DWORD sock_flags
Definition: sock.c:144
#define min(a, b)
Definition: monoChain.cc:55
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
char * send_buf
Definition: sock.c:171
#define AF_INET
Definition: tcpip.h:117
#define LPTR
Definition: winbase.h:353
#define ok(value,...)
Definition: CImage.cpp:33
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
static DWORD tls
Definition: sock.c:224
static HANDLE server_ready
Definition: sock.c:227
#define htons(x)
Definition: module.h:213
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:128
static void client_stop ( void  )
static

Definition at line 538 of file sock.c.

Referenced by event_client(), oob_client(), simple_client(), and simple_mixed_client().

539 {
541  wsa_ok ( closesocket ( mem->s ), 0 ==, "closesocket error (%x): %d\n" );
542  LocalFree ( mem->send_buf );
543  LocalFree ( mem );
544  ExitThread(0);
545 }
#define closesocket
Definition: main.c:50
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:349
SOCKET s
Definition: sock.c:169
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
char * send_buf
Definition: sock.c:171
static DWORD tls
Definition: sock.c:224
static void compare_addrinfo ( ADDRINFO a,
ADDRINFO b 
)
static

Definition at line 389 of file sock.c.

Referenced by test_getaddrinfo().

390 {
391  for (; a && b ; a = a->ai_next, b = b->ai_next)
392  {
393  ok(a->ai_flags == b->ai_flags,
394  "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
395  ok(a->ai_family == b->ai_family,
396  "Wrong family %d != %d\n", a->ai_family, b->ai_family);
397  ok(a->ai_socktype == b->ai_socktype,
398  "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
399  ok(a->ai_protocol == b->ai_protocol,
400  "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
401  ok(a->ai_addrlen == b->ai_addrlen,
402  "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
403  ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
404  "Wrong address data\n");
405  if (a->ai_canonname && b->ai_canonname)
406  {
407  ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
408  a->ai_canonname, b->ai_canonname);
409  }
410  else
411  ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
412  a->ai_canonname, b->ai_canonname);
413  }
414  ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
415 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define b
Definition: ke_i.h:79
char * ai_canonname
Definition: ws2def.h:670
int ai_protocol
Definition: ws2def.h:668
int ai_socktype
Definition: ws2def.h:667
#define min(a, b)
Definition: monoChain.cc:55
struct addrinfo * ai_next
Definition: ws2def.h:672
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: CImage.cpp:33
size_t ai_addrlen
Definition: ws2def.h:669
int ai_flags
Definition: ws2def.h:665
struct sockaddr * ai_addr
Definition: ws2def.h:671
int ai_family
Definition: ws2def.h:666
static void compare_addrinfow ( ADDRINFOW a,
ADDRINFOW b 
)
static

Definition at line 417 of file sock.c.

Referenced by test_GetAddrInfoW().

418 {
419  for (; a && b ; a = a->ai_next, b = b->ai_next)
420  {
421  ok(a->ai_flags == b->ai_flags,
422  "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
423  ok(a->ai_family == b->ai_family,
424  "Wrong family %d != %d\n", a->ai_family, b->ai_family);
425  ok(a->ai_socktype == b->ai_socktype,
426  "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
427  ok(a->ai_protocol == b->ai_protocol,
428  "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
429  ok(a->ai_addrlen == b->ai_addrlen,
430  "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
431  ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
432  "Wrong address data\n");
433  if (a->ai_canonname && b->ai_canonname)
434  {
435  ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
436  wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
437  }
438  else
439  ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
440  a->ai_canonname, b->ai_canonname);
441  }
442  ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
443 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
struct addrinfoW * ai_next
Definition: ws2def.h:683
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
int ai_family
Definition: ws2def.h:677
size_t ai_addrlen
Definition: ws2def.h:680
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
int ai_protocol
Definition: ws2def.h:679
#define b
Definition: ke_i.h:79
int ai_socktype
Definition: ws2def.h:678
int ai_flags
Definition: ws2def.h:676
#define min(a, b)
Definition: monoChain.cc:55
struct sockaddr * ai_addr
Definition: ws2def.h:682
#define ok(value,...)
Definition: CImage.cpp:33
PWSTR ai_canonname
Definition: ws2def.h:681
static void compare_file2 ( HANDLE  handle,
SOCKET  sock,
int  offset,
const char file,
int  line 
)
static

Definition at line 8593 of file sock.c.

8594 {
8595  char buf1[256], buf2[256];
8596  BOOL success;
8597  int i = 0;
8598 
8600  while (1)
8601  {
8602  DWORD n1 = 0, n2 = 0;
8603 
8604  success = ReadFile(handle, buf1, sizeof(buf1), &n1, NULL);
8605  ok_(file,line)(success, "Failed to read from file.\n");
8606  if (success && n1 == 0)
8607  break;
8608  else if(!success)
8609  return;
8610  n2 = recv(sock, buf2, n1, 0);
8611  ok_(file,line)(n1 == n2, "Block %d size mismatch (%d != %d)\n", i, n1, n2);
8612  ok_(file,line)(memcmp(buf1, buf2, n2) == 0, "Block %d failed\n", i);
8613  i++;
8614  }
8615 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
DWORD DWORD
Definition: winlogon.h:75
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:557
Definition: parser.c:48
unsigned int BOOL
Definition: ntddk_ex.h:94
#define success(from, fromstr, to, tostr)
int n1
Definition: dwarfget.c:148
#define FILE_BEGIN
Definition: winbase.h:110
int n2
Definition: dwarfget.c:148
Definition: tcpcore.h:1455
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define ok_(x1, x2)
Definition: CString.cpp:56
GLintptr offset
Definition: glext.h:5920
Definition: fci.c:114
static HWND create_async_message_window ( void  )
static

Definition at line 9273 of file sock.c.

Referenced by test_WSAAsyncGetServByName(), and test_WSAAsyncGetServByPort().

9274 {
9275  static const char class_name[] = "ws2_32 async message window class";
9276 
9277  WNDCLASSEXA wndclass;
9278  HWND hWnd;
9279 
9280  wndclass.cbSize = sizeof(wndclass);
9281  wndclass.style = CS_HREDRAW | CS_VREDRAW;
9282  wndclass.lpfnWndProc = DefWindowProcA;
9283  wndclass.cbClsExtra = 0;
9284  wndclass.cbWndExtra = 0;
9285  wndclass.hInstance = GetModuleHandleA(NULL);
9286  wndclass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
9288  wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
9289  wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
9290  wndclass.lpszClassName = class_name;
9291  wndclass.lpszMenuName = NULL;
9292 
9293  RegisterClassExA(&wndclass);
9294 
9295  hWnd = CreateWindowA(class_name, "ws2_32 async message window", WS_OVERLAPPEDWINDOW,
9296  0, 0, 500, 500, NULL, NULL, GetModuleHandleA(NULL), NULL);
9297  if (!hWnd)
9298  {
9299  ok(0, "failed to create window: %u\n", GetLastError());
9300  return NULL;
9301  }
9302 
9303  return hWnd;
9304 }
UINT style
Definition: winuser.h:3145
LPCSTR lpszMenuName
Definition: winuser.h:3153
HCURSOR hCursor
Definition: winuser.h:3151
WNDPROC lpfnWndProc
Definition: winuser.h:3146
LPCSTR lpszClassName
Definition: winuser.h:3154
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_APPLICATION
Definition: winuser.h:699
HICON hIconSm
Definition: winuser.h:3155
#define COLOR_WINDOW
Definition: winuser.h:898
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2031
HINSTANCE hInstance
Definition: winuser.h:3149
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4163
smooth NULL
Definition: ftsmooth.c:557
UINT cbSize
Definition: winuser.h:3144
const char * LPCSTR
Definition: xmlstorage.h:183
HBRUSH hbrBackground
Definition: winuser.h:3152
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3148
HICON hIcon
Definition: winuser.h:3150
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:818
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2061
int cbClsExtra
Definition: winuser.h:3147
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define ok(value,...)
Definition: CImage.cpp:33
static const char* dbgstr_event_seq ( const LPARAM seq)
static

Definition at line 5538 of file sock.c.

Referenced by ok_event_sequence().

5539 {
5540  static char message[1024];
5541  char name[12];
5542  int len = 1;
5543 
5544  message[0] = '[';
5545  message[1] = 0;
5546  while (*seq)
5547  {
5549  len += sprintf(message + len, "%s(%d) ", name, WSAGETSELECTERROR(*seq));
5550  seq++;
5551  }
5552  if (len > 1) len--;
5553  strcpy( message + len, "]" );
5554  return message;
5555 }
Definition: tftpd.h:59
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:557
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
GLenum GLsizei len
Definition: glext.h:6722
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
Definition: name.c:23
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static void get_event_details(int event, int *bit, char *name)
Definition: sock.c:5504
static char* dbgstr_event_seq_result ( SOCKET  s,
WSANETWORKEVENTS netEvents 
)
static

Definition at line 5557 of file sock.c.

Referenced by ok_event_sequence().

5558 {
5559  static char message[1024];
5560  struct async_message *curr = messages_received;
5561  int index, error, bit = 0;
5562  char name[12];
5563  int len = 1;
5564 
5565  message[0] = '[';
5566  message[1] = 0;
5567  while (1)
5568  {
5569  if (netEvents)
5570  {
5571  if (bit >= FD_MAX_EVENTS) break;
5572  if ( !(netEvents->lNetworkEvents & (1 << bit)) )
5573  {
5574  bit++;
5575  continue;
5576  }
5577  get_event_details(1 << bit, &index, name);
5578  error = netEvents->iErrorCode[index];
5579  bit++;
5580  }
5581  else
5582  {
5583  if (!curr) break;
5584  if (curr->socket != s)
5585  {
5586  curr = curr->next;
5587  continue;
5588  }
5590  error = WSAGETSELECTERROR(curr->lparam);
5591  curr = curr->next;
5592  }
5593 
5594  len += sprintf(message + len, "%s(%d) ", name, error);
5595  }
5596  if (len > 1) len--;
5597  strcpy( message + len, "]" );
5598  return message;
5599 }
Definition: tftpd.h:59
#define FD_MAX_EVENTS
Definition: winsock2.h:313
#define error(str)
Definition: mkdosfs.c:1605
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
struct async_message * next
Definition: sock.c:5472
SOCKET socket
Definition: sock.c:5470
static struct async_message * messages_received
Definition: sock.c:5475
#define sprintf(buf, format,...)
Definition: sprintf.c:55
LPARAM lparam
Definition: sock.c:5471
smooth NULL
Definition: ftsmooth.c:557
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
#define index(s, c)
Definition: various.h:29
GLdouble s
Definition: gl.h:2039
GLenum GLsizei len
Definition: glext.h:6722
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
Definition: name.c:23
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static void get_event_details(int event, int *bit, char *name)
Definition: sock.c:5504
static void do_bind ( SOCKET  s,
struct sockaddr addr,
int  addrlen 
)
static

Definition at line 452 of file sock.c.

Referenced by SelectReadThread(), server_start(), and test_UDP().

453 {
454  int err, wsaerr = 0, n_try = BIND_TRIES;
455 
456  while ( ( err = bind ( s, addr, addrlen ) ) != 0 &&
457  ( wsaerr = WSAGetLastError () ) == WSAEADDRINUSE &&
458  n_try-- >= 0)
459  {
460  trace ( "address in use, waiting ...\n" );
461  Sleep ( 1000 * BIND_SLEEP );
462  }
463  ok ( err == 0, "failed to bind: %d\n", wsaerr );
464 }
#define trace(...)
Definition: kmt_test.h:172
#define BIND_SLEEP
Definition: sock.c:45
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define BIND_TRIES
Definition: sock.c:46
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLdouble s
Definition: gl.h:2039
#define err(...)
#define ok(value,...)
Definition: CImage.cpp:33
#define WSAEADDRINUSE
Definition: winerror.h:1961
static DWORD WINAPI do_getservbyname ( void param)
static

Definition at line 2292 of file sock.c.

Referenced by test_getservbyname().

2293 {
2294  struct {
2295  const char *name;
2296  const char *proto;
2297  int port;
2298  } serv[2] = { {"domain", "udp", 53}, {"telnet", "tcp", 23} };
2299 
2300  HANDLE *starttest = param;
2301  int i, j;
2302  struct servent *pserv[2];
2303 
2304  ok ( WaitForSingleObject ( *starttest, TEST_TIMEOUT * 1000 ) != WAIT_TIMEOUT,
2305  "test_getservbyname: timeout waiting for start signal\n" );
2306 
2307  /* ensure that necessary buffer resizes are completed */
2308  for ( j = 0; j < 2; j++) {
2309  pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
2310  }
2311 
2312  for ( i = 0; i < NUM_QUERIES / 2; i++ ) {
2313  for ( j = 0; j < 2; j++ ) {
2314  pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
2315  ok ( pserv[j] != NULL || broken(pserv[j] == NULL) /* win8, fixed in win81 */,
2316  "getservbyname could not retrieve information for %s: %d\n", serv[j].name, WSAGetLastError() );
2317  if ( !pserv[j] ) continue;
2318  ok ( pserv[j]->s_port == htons(serv[j].port),
2319  "getservbyname returned the wrong port for %s: %d\n", serv[j].name, ntohs(pserv[j]->s_port) );
2320  ok ( !strcmp ( pserv[j]->s_proto, serv[j].proto ),
2321  "getservbyname returned the wrong protocol for %s: %s\n", serv[j].name, pserv[j]->s_proto );
2322  ok ( !strcmp ( pserv[j]->s_name, serv[j].name ),
2323  "getservbyname returned the wrong name for %s: %s\n", serv[j].name, pserv[j]->s_name );
2324  }
2325 
2326  ok ( pserv[0] == pserv[1] || broken(pserv[0] != pserv[1]) /* win8, fixed in win81 */,
2327  "getservbyname: winsock resized servent buffer when not necessary\n" );
2328  }
2329 
2330  return 0;
2331 }
#define NUM_QUERIES
Definition: sock.c:53
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TEST_TIMEOUT
Definition: sock.c:47
#define ntohs(x)
Definition: module.h:208
GLuint const GLchar * name
Definition: glext.h:6031
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:557
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
PSERVENT WSAAPI getservbyname(IN const char FAR *name, IN const char FAR *proto)
Definition: getxbyxx.c:500
GLfloat param
Definition: glext.h:5796
char * s_name
Definition: winsock.h:159
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define broken(x)
Definition: _sntprintf.h:21
DWORD *typedef HANDLE
Definition: winlogon.h:52
short s_port
Definition: winsock.h:165
Definition: name.c:23
char * s_proto
Definition: winsock.h:166
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: CImage.cpp:33
#define htons(x)
Definition: module.h:213
USHORT port
Definition: uri.c:219
static int do_synchronous_recv ( SOCKET  s,
char buf,
int  buflen,
int  flags,
int  recvlen 
)
static

Definition at line 351 of file sock.c.

Referenced by oob_client(), oob_server(), simple_client(), and simple_server().

352 {
353  char* last = buf + buflen, *p;
354  int n = 1;
355  for ( p = buf; n > 0 && p < last; )
356  {
357  n = recv ( s, p, min ( recvlen, last - p ), flags );
358  if (n > 0) p += n;
359  }
360  wsa_ok ( n, 0 <=, "do_synchronous_recv (%x): error %d:\n" );
361  return p - buf;
362 }
POINT last
Definition: font.c:45
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint n
Definition: s_context.h:57
GLbitfield flags
Definition: glext.h:7161
GLdouble s
Definition: gl.h:2039
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define min(a, b)
Definition: monoChain.cc:55
GLfloat GLfloat p
Definition: glext.h:8902
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static int do_synchronous_recvfrom ( SOCKET  s,
char buf,
int  buflen,
int  flags,
struct sockaddr from,
int fromlen,
int  recvlen 
)
static

Definition at line 364 of file sock.c.

Referenced by simple_mixed_client().

365 {
366  char* last = buf + buflen, *p;
367  int n = 1;
368  for ( p = buf; n > 0 && p < last; )
369  {
370  n = recvfrom ( s, p, min ( recvlen, last - p ), flags, from, fromlen );
371  if (n > 0) p += n;
372  }
373  wsa_ok ( n, 0 <=, "do_synchronous_recv (%x): error %d:\n" );
374  return p - buf;
375 }
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
POINT last
Definition: font.c:45
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint n
Definition: s_context.h:57
GLbitfield flags
Definition: glext.h:7161
GLdouble s
Definition: gl.h:2039
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define min(a, b)
Definition: monoChain.cc:55
GLfloat GLfloat p
Definition: glext.h:8902
static int do_synchronous_send ( SOCKET  s,
char buf,
int  buflen,
int  flags,
int  sendlen 
)
static

Definition at line 338 of file sock.c.

Referenced by oob_client(), oob_server(), simple_client(), simple_mixed_client(), and simple_server().

339 {
340  char* last = buf + buflen, *p;
341  int n = 1;
342  for ( p = buf; n > 0 && p < last; )
343  {
344  n = send ( s, p, min ( sendlen, last - p ), flags );
345  if (n > 0) p += n;
346  }
347  wsa_ok ( n, 0 <=, "do_synchronous_send (%x): error %d\n" );
348  return p - buf;
349 }
POINT last
Definition: font.c:45
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint n
Definition: s_context.h:57
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
GLbitfield flags
Definition: glext.h:7161
GLdouble s
Definition: gl.h:2039
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define min(a, b)
Definition: monoChain.cc:55
GLfloat GLfloat p
Definition: glext.h:8902
static void do_test ( test_setup test)
static

Definition at line 1304 of file sock.c.

Referenced by START_TEST().

1305 {
1306  DWORD i, n = min (test->general.n_clients, MAX_CLIENTS);
1307  DWORD wait;
1308 
1310  for (i = 0; i <= n; i++)
1312 
1313  StartServer ( test->srv, &test->general, &test->srv_params );
1314  StartClients ( test->clt, &test->general, &test->clt_params );
1316 
1317  wait = WaitForMultipleObjects ( 1 + n, thread, TRUE, 1000 * TEST_TIMEOUT );
1318  ok ( wait <= WAIT_OBJECT_0 + n ,
1319  "some threads have not completed: %x\n", wait );
1320 
1321  if ( ! ( wait <= WAIT_OBJECT_0 + n ) )
1322  {
1323  for (i = 0; i <= n; i++)
1324  {
1325  if ( WaitForSingleObject ( thread[i], 0 ) != WAIT_OBJECT_0 )
1326  {
1327  trace ("terminating thread %08x\n", thread_id[i]);
1328  TerminateThread ( thread [i], 0 );
1329  }
1330  }
1331  }
1333  for (i = 0; i <= n; i++)
1334  CloseHandle ( client_ready[i] );
1335 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define TEST_TIMEOUT
Definition: sock.c:47
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:571
static void StartClients(LPTHREAD_START_ROUTINE routine, test_params *general, client_params *par)
Definition: sock.c:1289
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD DWORD
Definition: winlogon.h:75
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:225
test_params general
Definition: sock.c:151
GLuint n
Definition: s_context.h:57
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:583
#define MAX_CLIENTS
Definition: sock.c:43
#define WAIT_OBJECT_0
Definition: winbase.h:378
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:226
server_params srv_params
Definition: sock.c:153
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:228
LPVOID srv
Definition: sock.c:152
client_params clt_params
Definition: sock.c:155
LPVOID clt
Definition: sock.c:154
int n_clients
Definition: sock.c:129
#define min(a, b)
Definition: monoChain.cc:55
static void StartServer(LPTHREAD_START_ROUTINE routine, test_params *general, server_params *par)
Definition: sock.c:1281
#define ok(value,...)
Definition: CImage.cpp:33
static HANDLE server_ready
Definition: sock.c:227
#define INFINITE
Definition: serial.h:102
static DWORD WINAPI drain_socket_thread ( LPVOID  arg)
static

Definition at line 5301 of file sock.c.

Referenced by test_events(), and test_send().

5302 {
5303  char buffer[1024];
5304  SOCKET sock = *(SOCKET*)arg;
5305  int ret;
5306 
5307  while ((ret = recv(sock, buffer, sizeof(buffer), 0)) != 0)
5308  {
5309  if (ret < 0)
5310  {
5312  {
5313  fd_set readset;
5314  FD_ZERO(&readset);
5315  FD_SET(sock, &readset);
5316  select(sock+1, &readset, NULL, NULL, NULL);
5317  while (drain_pause)
5318  Sleep(100);
5319  }
5320  else
5321  break;
5322  }
5323  }
5324  return 0;
5325 }
Definition: winsock.h:66
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLuint buffer
Definition: glext.h:5915
#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
smooth NULL
Definition: ftsmooth.c:557
static BOOL drain_pause
Definition: sock.c:5300
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
int ret
Definition: tcpcore.h:1455
UINT_PTR SOCKET
Definition: winsock.h:47
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static DWORD ( WINAPI pGetAdaptersInfo)
static
static void WINAPI event_client ( client_params par)
static

Definition at line 988 of file sock.c.

989 {
990  test_params *gen = par->general;
992  int id = GetCurrentThreadId(), n_expected = gen->n_chunks * gen->chunk_size,
993  tmp, err, n;
994  HANDLE event;
995  WSANETWORKEVENTS wsa_events;
996  char *send_last, *recv_last, *send_p, *recv_p;
998 
999  trace ( "event_client (%x): starting\n", id );
1000  client_start ( par );
1001  trace ( "event_client (%x): server ready\n", id );
1002 
1003  mem = TlsGetValue ( tls );
1004 
1005  /* Prepare event notification for connect, makes socket nonblocking */
1006  event = WSACreateEvent ();
1007  WSAEventSelect ( mem->s, event, FD_CONNECT );
1008  tmp = connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) );
1009  if ( tmp != 0 ) {
1010  err = WSAGetLastError ();
1011  ok ( err == WSAEWOULDBLOCK, "event_client (%x): connect error: %d\n", id, err );
1012  tmp = WaitForSingleObject ( event, INFINITE );
1013  ok ( tmp == WAIT_OBJECT_0, "event_client (%x): wait for connect event failed: %d\n", id, tmp );
1014  err = WSAEnumNetworkEvents ( mem->s, event, &wsa_events );
1015  ok ( err == 0, "event_client (%x): WSAEnumNetworkEvents error: %d\n", id, err );
1016  err = wsa_events.iErrorCode[ FD_CONNECT_BIT ];
1017  ok ( err == 0, "event_client (%x): connect error: %d\n", id, err );
1018  if ( err ) goto out;
1019  }
1020 
1021  trace ( "event_client (%x) connected\n", id );
1022 
1023  WSAEventSelect ( mem->s, event, mask );
1024 
1025  recv_p = mem->recv_buf;
1026  recv_last = mem->recv_buf + n_expected;
1027  send_p = mem->send_buf;
1028  send_last = mem->send_buf + n_expected;
1029 
1030  while ( TRUE )
1031  {
1032  err = WaitForSingleObject ( event, INFINITE );
1033  ok ( err == WAIT_OBJECT_0, "event_client (%x): wait failed\n", id );
1034 
1035  err = WSAEnumNetworkEvents ( mem->s, event, &wsa_events );
1036  ok( err == 0, "event_client (%x): WSAEnumNetworkEvents error: %d\n", id, err );
1037 
1038  if ( wsa_events.lNetworkEvents & FD_WRITE )
1039  {
1040  err = wsa_events.iErrorCode[ FD_WRITE_BIT ];
1041  ok ( err == 0, "event_client (%x): FD_WRITE error code: %d\n", id, err );
1042 
1043  if ( err== 0 )
1044  do
1045  {
1046  n = send ( mem->s, send_p, min ( send_last - send_p, par->buflen ), 0 );
1047  if ( n < 0 )
1048  {
1049  err = WSAGetLastError ();
1050  ok ( err == WSAEWOULDBLOCK, "event_client (%x): send error: %d\n", id, err );
1051  }
1052  else
1053  send_p += n;
1054  }
1055  while ( n >= 0 && send_p < send_last );
1056 
1057  if ( send_p == send_last )
1058  {
1059  trace ( "event_client (%x): all data sent - shutdown\n", id );
1060  shutdown ( mem->s, SD_SEND );
1061  mask &= ~FD_WRITE;
1062  WSAEventSelect ( mem->s, event, mask );
1063  }
1064  }
1065  if ( wsa_events.lNetworkEvents & FD_READ )
1066  {
1067  err = wsa_events.iErrorCode[ FD_READ_BIT ];
1068  ok ( err == 0, "event_client (%x): FD_READ error code: %d\n", id, err );
1069  if ( err != 0 ) break;
1070 
1071  /* First read must succeed */
1072  n = recv ( mem->s, recv_p, min ( recv_last - recv_p, par->buflen ), 0 );
1073  wsa_ok ( n, 0 <=, "event_client (%x): recv error: %d\n" );
1074 
1075  while ( n >= 0 ) {
1076  recv_p += n;
1077  if ( recv_p == recv_last )
1078  {
1079  mask &= ~FD_READ;
1080  trace ( "event_client (%x): all data received\n", id );
1081  WSAEventSelect ( mem->s, event, mask );
1082  break;
1083  }
1084  n = recv ( mem->s, recv_p, min ( recv_last - recv_p, par->buflen ), 0 );
1085  if ( n < 0 && ( err = WSAGetLastError()) != WSAEWOULDBLOCK )
1086  ok ( 0, "event_client (%x): read error: %d\n", id, err );
1087 
1088  }
1089  }
1090  if ( wsa_events.lNetworkEvents & FD_CLOSE )
1091  {
1092  trace ( "event_client (%x): close event\n", id );
1093  err = wsa_events.iErrorCode[ FD_CLOSE_BIT ];
1094  ok ( err == 0, "event_client (%x): FD_CLOSE error code: %d\n", id, err );
1095  break;
1096  }
1097  }
1098 
1099  n = send_p - mem->send_buf;
1100  ok ( send_p == send_last,
1101  "simple_client (%x): sent less data than expected: %d of %d\n", id, n, n_expected );
1102  n = recv_p - mem->recv_buf;
1103  ok ( recv_p == recv_last,
1104  "simple_client (%x): received less data than expected: %d of %d\n", id, n, n_expected );
1105  n = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
1106  ok ( n == -1, "event_client (%x): test pattern error: %d\n", id, n);
1107 
1108 out:
1109  WSACloseEvent ( event );
1110  trace ( "event_client (%x) exiting\n", id );
1111  client_stop ();
1112 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:143
char * recv_buf
Definition: sock.c:172
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define FD_CONNECT
Definition: winsock.h:409
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define FD_CONNECT_BIT
Definition: winsock2.h:301
#define FD_READ
Definition: winsock.h:405
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define FD_WRITE
Definition: winsock.h:406
GLuint n
Definition: s_context.h:57
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLenum GLint GLuint mask
Definition: glext.h:6028
long LONG
Definition: pedump.c:60
INT WSAAPI WSAEventSelect(IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
Definition: select.c:182
BOOL WSAAPI WSACloseEvent(IN WSAEVENT hEvent)
Definition: event.c:23
#define FD_READ_BIT
Definition: winsock2.h:293
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define FD_CLOSE_BIT
Definition: winsock2.h:303
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define WAIT_OBJECT_0
Definition: winbase.h:378
#define FD_CLOSE
Definition: winsock.h:410
struct sockaddr_in addr
Definition: sock.c:170
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
SOCKET s
Definition: sock.c:169
static FILE * out
Definition: regtests2xml.c:44
int buflen
Definition: sock.c:145
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
#define err(...)
struct _cl_event * event
Definition: glext.h:7739
static void client_start(client_params *par)
Definition: sock.c:511
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
DWORD *typedef HANDLE
Definition: winlogon.h:52
WSAEVENT WSAAPI WSACreateEvent(VOID)
Definition: event.c:42
#define SD_SEND
Definition: winsock.h:55
#define min(a, b)
Definition: monoChain.cc:55
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
char * send_buf
Definition: sock.c:171
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:128
static void client_stop(void)
Definition: sock.c:538
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define FD_WRITE_BIT
Definition: winsock2.h:295
static void Exit ( void  )
static

Definition at line 1272 of file sock.c.

Referenced by _bdf_add_comment(), _bdf_add_property(), _bdf_list_ensure(), _bdf_list_split(), _bdf_parse_glyphs(), _bdf_parse_properties(), _bdf_parse_start(), _bdf_readstream(), _bdf_set_default_spacing(), _Success_(), AcpiDsEvaluateNamePath(), AcpiEvaluateObjectTyped(), AcpiEvOrphanEcRegMethod(), AcpiExCreateMethod(), AcpiExInsertIntoField(), AcpiExReadDataFromField(), AcpiExResolveMultiple(), AcpiHwClearAcpiStatus(), AcpiHwRegisterWrite(), AcpiInstallSciHandler(), AcpiNsCheckReturnValue(), AcpiNsExecModuleCode(), AcpiRsConvertAmlToResource(), AcpiRsConvertResourceToAml(), AcpiTbInstallAndLoadTable(), AcpiUtAllocateOwnerId(), AcpiUtStrtoulBase10(), AcpiUtStrtoulBase16(), af_axis_hints_new_edge(), af_axis_hints_new_segment(), af_face_globals_compute_style_coverage(), af_face_globals_get_metrics(), af_face_globals_new(), af_glyph_hints_reload(), af_latin_hints_apply(), af_latin_hints_compute_edges(), af_latin_hints_compute_segments(), af_latin_metrics_init_widths(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), bdf_cmap_char_next(), bdf_create_property(), BDF_Face_Init(), BDF_Glyph_Load(), bdf_load_font(), cff_blend_build_vector(), cff_blend_doBlend(), cff_charset_compute_cids(), cff_charset_load(), cff_decoder_prepare(), cff_encoding_load(), cff_face_init(), cff_fd_select_get(), cff_font_load(), cff_get_glyph_name(), cff_index_access_element(), cff_index_get_name(), cff_index_get_pointers(), cff_index_init(), cff_index_load_offsets(), CFF_Load_FD_Select(), cff_load_private_dict(), cff_parse_blend(), cff_parse_font_matrix(), cff_parse_integer(), cff_parse_maxstack(), cff_parse_real(), cff_parse_vsindex(), cff_parser_init(), cff_parser_run(), cff_size_init(), cff_subfont_load(), cff_vstore_load(), check_table_dir(), check_type1_format(), cid_face_init(), cid_face_open(), cid_hex_to_binary(), cid_load_glyph(), cid_load_keyword(), cid_parser_new(), cid_read_subrs(), cid_slot_load_glyph(), classic_kern_validate(), CmpCreateLinkNode(), CmpDoCreate(), CmpGetSymbolicLink(), CmpRemoveSubKey(), co_HOOK_CallHooks(), co_IntProcessKeyboardMessage(), co_MsqDispatchOneSentMessage(), CreateDIBitmap(), DefSetText(), DispTdiQueryIpHwAddress(), DoAppSwitch(), EnumHKCRKey(), EnumHKCRValue(), fnt_face_get_dll_font(), FNT_Face_Init(), fnt_font_load(), FNT_Load_Glyph(), FT_Add_Module(), ft_add_renderer(), FT_Attach_Stream(), ft_bitmap_glyph_init(), FT_ClassicKern_Validate(), FT_CMap_New(), FT_DEFINE_GLYPH(), FT_Done_Library(), FT_Face_Properties(), FT_Get_Gasp(), FT_Get_Glyph(), FT_Get_Postscript_Name(), FT_Glyph_Copy(), FT_Glyph_Stroke(), FT_Glyph_StrokeBorder(), FT_Glyph_To_Bitmap(), FT_GlyphLoader_CheckPoints(), FT_GlyphLoader_CheckSubGlyphs(), ft_glyphslot_init(), FT_Load_Glyph(), FT_Lookup_Renderer(), ft_lzwstate_io(), FT_New_GlyphSlot(), FT_New_Size(), ft_open_face_internal(), FT_OpenType_Validate(), FT_Outline_Decompose(), FT_Raccess_Get_DataOffsets(), ft_raster1_render(), ft_raster1_transform(), FT_Set_Renderer(), ft_smooth_render_generic(), ft_smooth_transform(), FT_Stream_EnterFrame(), FT_Stream_New(), FT_Stream_ReadFields(), FT_Stream_TryRead(), ft_stroke_border_get_counts(), ft_stroke_border_grow(), ft_stroker_add_reverse_left(), ft_stroker_cap(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), FT_Stroker_EndSubPath(), FT_Stroker_GetBorderCounts(), FT_Stroker_GetCounts(), FT_Stroker_LineTo(), ft_stroker_outside(), FT_Stroker_ParseOutline(), ft_stroker_process_corner(), ft_stroker_subpath_start(), FT_TrueTypeGX_Validate(), ftc_basic_family_load_glyph(), FTC_CMapCache_Lookup(), FTC_ImageCache_Lookup(), FTC_ImageCache_LookupScaler(), FTC_Manager_New(), FTC_Manager_RegisterCache(), FTC_MruList_New(), FTC_SBitCache_Lookup(), FTC_SBitCache_LookupScaler(), ftc_scaler_lookup_size(), FTC_SNode_New(), ftGdiGetTextCharsetInfo(), gxv_feat_registry_validate(), gxv_kern_coverage_validate(), gxv_kern_subtable_validate(), gxv_lcar_partial_validate(), gxv_load_table(), gxv_prop_validate(), gxv_sfntName_validate(), gxv_validate(), gxv_XEntryTable_validate(), hash_insert(), hash_rehash(), Horizontal_Sweep_Drop(), IntCallWindowProcA(), IntCallWindowProcW(), CSettings::Load(), load_truetype_glyph(), main(), MapAnsiQuerySetToUnicode(), MapUnicodeQuerySetToAnsi(), MiDoMappedCopy(), MiDoPoolCopy(), MmPapAllocatePagesInRange(), NtAreMappedFilesTheSame(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphOutline(), NtGdiSelectClipPath(), NtGdiSetDIBitsToDeviceInternal(), NtGdiSetPixelFormat(), NtGdiSwapBuffers(), NtSetSystemPowerState(), NtStopProfile(), NtUserAttachThreadInput(), NtUserBuildPropList(), NtUserDeferWindowPos(), NtUserDefSetText(), NtUserDrawCaptionTemp(), NtUserFillWindow(), NtUserFlashWindowEx(), NtUserGetInternalWindowPos(), NtUserGetLayeredWindowAttributes(), NtUserGetObjectInformation(), NtUserMinMaximize(), NtUserPrintWindow(), NtUserRemoveProp(), NtUserSetCursorIconData(), NtUserSetLayeredWindowAttributes(), NtUserSetProp(), NtUserSetSystemCursor(), NtUserTrackPopupMenuEx(), NtUserUpdateLayeredWindow(), NtUserVkKeyScanEx(), otv_load_table(), otv_validate(), parse_blend_axis_types(), parse_blend_design_map(), parse_blend_design_positions(), parse_dict(), parse_fd_array(), parse_weight_vector(), pcf_cmap_char_next(), PCF_Face_Init(), pcf_get_metric(), PCF_Glyph_Load(), pcf_load_font(), pcf_read_TOC(), pfr_aux_name_load(), pfr_cmap_char_next(), pfr_cmap_init(), pfr_extra_item_load_bitmap_info(), pfr_extra_item_load_font_id(), pfr_extra_item_load_kerning_pairs(), pfr_extra_item_load_stem_snaps(), pfr_extra_items_parse(), pfr_face_get_kerning(), pfr_face_init(), pfr_get_advance(), pfr_glyph_curve_to(), pfr_glyph_line_to(), pfr_glyph_load_compound(), pfr_glyph_load_rec(), pfr_glyph_load_simple(), pfr_load_bitmap_metrics(), pfr_log_font_count(), pfr_log_font_load(), pfr_phy_font_load(), pfr_slot_load(), PipCallDriverAddDevice(), PreloadGlobalMessageTable(), PS_Conv_ToFixed(), ps_dimension_add_counter(), ps_dimension_add_t1stem(), ps_dimension_set_mask_bits(), ps_hint_table_alloc(), ps_hints_apply(), ps_mask_set_bit(), ps_mask_table_alloc(), ps_mask_table_last(), ps_mask_table_merge(), ps_mask_table_merge_all(), ps_mask_table_set_bits(), ps_parser_load_field(), ps_parser_load_field_table(), ps_parser_to_bytes(), ps_table_new(), ps_tocoordarray(), ps_tofixedarray(), psh_glyph_init(), psh_hint_table_init(), RegCreateKeyExA(), RegEnumKeyExA(), RegEnumValueA(), RegLoadKeyA(), RegReplaceKeyA(), sfnt_load_face(), START_TEST(), t1_allocate_blend(), t1_cmap_custom_char_next(), t1_cmap_std_char_next(), T1_Face_Init(), T1_Get_MM_Var(), T1_Get_Private_Dict(), T1_Load_Glyph(), t1_load_keyword(), T1_New_Parser(), T1_Open_Face(), T1_Read_Metrics(), T1_Read_PFM(), t1operator_seac(), T42_Face_Init(), t42_load_keyword(), T42_Open_Face(), t42_parse_dict(), t42_parse_sfnts(), t42_parser_init(), tt_face_get_name(), tt_face_goto_table(), tt_face_init(), tt_face_load_any(), tt_face_load_cmap(), tt_face_load_cvt(), tt_face_load_font_dir(), tt_face_load_fpgm(), tt_face_load_gasp(), tt_face_load_generic_header(), tt_face_load_hdmx(), tt_face_load_kern(), tt_face_load_loca(), tt_face_load_maxp(), tt_face_load_name(), tt_face_load_os2(), tt_face_load_pclt(), tt_face_load_prep(), TT_Load_Glyph(), USBH_ChangeIndicationWorker(), USBH_CheckDeviceLanguage(), USBH_CheckHubIdle(), USBH_CreateDevice(), USBH_FdoCleanup(), USBH_FdoPower(), USBH_GetSerialNumberString(), USBH_IoctlGetDescriptor(), USBH_IoctlGetNodeConnectionAttributes(), USBH_IoctlGetNodeConnectionDriverKeyName(), USBH_IoctlGetNodeConnectionInformation(), USBH_IoctlGetNodeName(), USBH_PdoInternalControl(), USBH_PdoQueryDeviceText(), USBH_ResetDevice(), USBH_ResetPortWorker(), USBH_StartHubFdoDevice(), USBH_SyncResetPort(), USBPORT_AllocateCommonBuffer(), USBPORT_FdoPnP(), USBPORT_FindCompanionControllers(), USBPORT_GetSymbolicName(), USBPORT_HandleSelectConfiguration(), USBPORT_MiniportCompleteTransfer(), USBPORT_OpenInterface(), USBPORT_PdoInternalDeviceControl(), USBPORT_SplitBulkInterruptTransfer(), USBPORT_TimerDpc(), UserSetCursorIconData(), Vertical_Sweep_Drop(), woff_open_font(), WsAsyncCheckAndInitThread(), and WsNqLookupServiceBegin().

1273 {
1274  INT ret, err;
1275  TlsFree ( tls );
1276  ret = WSACleanup();
1277  err = WSAGetLastError();
1278  ok ( ret == 0, "WSACleanup failed ret = %d GetLastError is %d\n", ret, err);
1279 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
int32_t INT
Definition: typedefs.h:56
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1111
int ret
#define err(...)
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static void fill_buffer ( char buf,
int  chunk_size,
int  n_chunks 
)
static

Definition at line 306 of file sock.c.

Referenced by client_start().

307 {
308  char c, *p;
309  for ( c = FIRST_CHAR, p = buf; c < FIRST_CHAR + n_chunks; c++, p += chunk_size )
310  memset ( p, c, chunk_size );
311 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FIRST_CHAR
Definition: sock.c:44
#define c
Definition: ke_i.h:80
GLfloat GLfloat p
Definition: glext.h:8902
#define memset(x, y, z)
Definition: compat.h:39
static void flush_events ( SOCKET  s,
HANDLE  hEvent 
)
static

Definition at line 5601 of file sock.c.

Referenced by ok_event_sequence(), and test_events().

5602 {
5603  WSANETWORKEVENTS netEvents;
5604  struct async_message *prev = NULL, *curr = messages_received;
5605  int ret;
5606  DWORD dwRet;
5607 
5609  {
5610  dwRet = WaitForSingleObject(hEvent, 100);
5611  if (dwRet == WAIT_OBJECT_0)
5612  {
5613  ret = WSAEnumNetworkEvents(s, hEvent, &netEvents);
5614  if (ret)
5615  ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5616  }
5617  }
5618  else
5619  {
5620  while (curr)
5621  {
5622  if (curr->socket == s)
5623  {
5624  if (prev) prev->next = curr->next;
5625  else messages_received = curr->next;
5626 
5627  HeapFree(GetProcessHeap(), 0, curr);
5628 
5629  if (prev) curr = prev->next;
5630  else curr = messages_received;
5631  }
5632  else
5633  {
5634  prev = curr;
5635  curr = curr->next;
5636  }
5637  }
5638  }
5639 }
struct async_message * next
Definition: sock.c:5472
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD DWORD
Definition: winlogon.h:75
static struct async_message * messages_received
Definition: sock.c:5475
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:557
#define WAIT_OBJECT_0
Definition: winbase.h:378
#define GetProcessHeap()
Definition: compat.h:395
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
int ret
GLdouble s
Definition: gl.h:2039
#define ok(value,...)
Definition: CImage.cpp:33
#define HeapFree(x, y, z)
Definition: compat.h:394
static void get_event_details ( int  event,
int bit,
char name 
)
static

Definition at line 5504 of file sock.c.

Referenced by dbgstr_event_seq(), dbgstr_event_seq_result(), and match_event_sequence().

5505 {
5506  switch (event)
5507  {
5508  case FD_ACCEPT:
5509  if (bit) *bit = FD_ACCEPT_BIT;
5510  if (name) strcpy(name, "FD_ACCEPT");
5511  break;
5512  case FD_CONNECT:
5513  if (bit) *bit = FD_CONNECT_BIT;
5514  if (name) strcpy(name, "FD_CONNECT");
5515  break;
5516  case FD_READ:
5517  if (bit) *bit = FD_READ_BIT;
5518  if (name) strcpy(name, "FD_READ");
5519  break;
5520  case FD_OOB:
5521  if (bit) *bit = FD_OOB_BIT;
5522  if (name) strcpy(name, "FD_OOB");
5523  break;
5524  case FD_WRITE:
5525  if (bit) *bit = FD_WRITE_BIT;
5526  if (name) strcpy(name, "FD_WRITE");
5527  break;
5528  case FD_CLOSE:
5529  if (bit) *bit = FD_CLOSE_BIT;
5530  if (name) strcpy(name, "FD_CLOSE");
5531  break;
5532  default:
5533  if (bit) *bit = -1;
5534  if (name) sprintf(name, "bad%x", event);
5535  }
5536 }
#define FD_ACCEPT
Definition: winsock.h:408
#define FD_CONNECT
Definition: winsock.h:409
#define FD_CONNECT_BIT
Definition: winsock2.h:301
#define FD_READ
Definition: winsock.h:405
#define FD_OOB_BIT
Definition: winsock2.h:297
#define FD_OOB
Definition: winsock.h:407
#define FD_WRITE
Definition: winsock.h:406
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define FD_READ_BIT
Definition: winsock2.h:293
#define FD_CLOSE_BIT
Definition: winsock2.h:303
#define FD_CLOSE
Definition: winsock.h:410
struct _cl_event * event
Definition: glext.h:7739
#define FD_ACCEPT_BIT
Definition: winsock2.h:299
Definition: name.c:23
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define FD_WRITE_BIT
Definition: winsock2.h:295
int WINAPI gethostname ( char name,
int  namelen 
)
static DWORD WINAPI inet_ntoa_thread_proc ( void param)
static

Definition at line 10325 of file sock.c.

Referenced by test_inet_ntoa().

10326 {
10327  ULONG addr;
10328  const char *str;
10329  HANDLE *event = param;
10330 
10331  addr = inet_addr("4.3.2.1");
10332  ok(addr == htonl(0x04030201), "expected 0x04030201, got %08x\n", addr);
10333  str = inet_ntoa(*(struct in_addr *)&addr);
10334  ok(!strcmp(str, "4.3.2.1"), "expected 4.3.2.1, got %s\n", str);
10335 
10336  SetEvent(event[0]);
10337  WaitForSingleObject(event[1], 3000);
10338 
10339  return 0;
10340 }
#define inet_addr(cp)
Definition: inet.h:98
#define htonl(x)
Definition: module.h:212
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const WCHAR * str
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: tcpip.h:125
GLfloat param
Definition: glext.h:5796
GLenum const GLvoid * addr
Definition: glext.h:9621
struct _cl_event * event
Definition: glext.h:7739
DWORD *typedef HANDLE
Definition: winlogon.h:52
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: CImage.cpp:33
static void Init ( void  )
static

Definition at line 1233 of file sock.c.

Referenced by START_TEST().

1234 {
1235  WORD ver = MAKEWORD (2, 2);
1236  WSADATA data;
1237  HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), hiphlpapi;
1238  HMODULE hntdll = GetModuleHandleA("ntdll.dll");
1239 
1240  pfreeaddrinfo = (void *)GetProcAddress(hws2_32, "freeaddrinfo");
1241  pgetaddrinfo = (void *)GetProcAddress(hws2_32, "getaddrinfo");
1242  pFreeAddrInfoW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoW");
1243  pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
1244  pGetAddrInfoW = (void *)GetProcAddress(hws2_32, "GetAddrInfoW");
1245  pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
1246  pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult");
1247  pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
1248  pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
1249  pInetPtonA = (void *)GetProcAddress(hws2_32, "inet_pton");
1250  pInetPtonW = (void *)GetProcAddress(hws2_32, "InetPtonW");
1251  pWSALookupServiceBeginW = (void *)GetProcAddress(hws2_32, "WSALookupServiceBeginW");
1252  pWSALookupServiceEnd = (void *)GetProcAddress(hws2_32, "WSALookupServiceEnd");
1253  pWSALookupServiceNextW = (void *)GetProcAddress(hws2_32, "WSALookupServiceNextW");
1254  pWSAEnumNameSpaceProvidersA = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersA");
1255  pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW");
1256  pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll");
1257 
1258  pNtSetInformationFile = (void *)GetProcAddress(hntdll, "NtSetInformationFile");
1259  pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
1260 
1261  hiphlpapi = LoadLibraryA("iphlpapi.dll");
1262  if (hiphlpapi)
1263  {
1264  pGetIpForwardTable = (void *)GetProcAddress(hiphlpapi, "GetIpForwardTable");
1265  pGetAdaptersInfo = (void *)GetProcAddress(hiphlpapi, "GetAdaptersInfo");
1266  }
1267 
1268  ok ( WSAStartup ( ver, &data ) == 0, "WSAStartup failed\n" );
1269  tls = TlsAlloc();
1270 }
unsigned short WORD
Definition: ntddk_ex.h:93
#define MAKEWORD(a, b)
Definition: typedefs.h:247
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:818
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1045
static HINSTANCE hntdll
Definition: process.c:64
HANDLE HMODULE
Definition: typedefs.h:75
#define GetProcAddress(x, y)
Definition: compat.h:410
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static void WINAPI io_completion ( DWORD  error,
DWORD  transferred,
WSAOVERLAPPED overlapped,
DWORD  flags 
)
static

Definition at line 6718 of file sock.c.

Referenced by test_WSARecv().

6719 {
6721 }
static int completion_called
Definition: sock.c:6716
static int match_event_sequence ( SOCKET  s,
WSANETWORKEVENTS netEvents,
const LPARAM seq 
)
static

Definition at line 5641 of file sock.c.

Referenced by ok_event_sequence().

5642 {
5643  int event, index, error, events;
5644  struct async_message *curr;
5645 
5646  if (netEvents)
5647  {
5648  events = netEvents->lNetworkEvents;
5649  while (*seq)
5650  {
5651  event = WSAGETSELECTEVENT(*seq);
5652  error = WSAGETSELECTERROR(*seq);
5653  get_event_details(event, &index, NULL);
5654 
5655  if (!(events & event) && index != -1)
5656  return 0;
5657  if (events & event && index != -1)
5658  {
5659  if (netEvents->iErrorCode[index] != error)
5660  return 0;
5661  }
5662  events &= ~event;
5663  seq++;
5664  }
5665  if (events)
5666  return 0;
5667  }
5668  else
5669  {
5670  curr = messages_received;
5671  while (curr)
5672  {
5673  if (curr->socket == s)
5674  {
5675  if (!*seq) return 0;
5676  if (*seq != curr->lparam) return 0;
5677  seq++;
5678  }
5679  curr = curr->next;
5680  }
5681  if (*seq)
5682  return 0;
5683  }
5684  return 1;
5685 }
#define error(str)
Definition: mkdosfs.c:1605
struct async_message * next
Definition: sock.c:5472
SOCKET socket
Definition: sock.c:5470
static struct async_message * messages_received
Definition: sock.c:5475
LPARAM lparam
Definition: sock.c:5471
smooth NULL
Definition: ftsmooth.c:557
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
#define index(s, c)
Definition: various.h:29
GLdouble s
Definition: gl.h:2039
struct _cl_event * event
Definition: glext.h:7739
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
HANDLE events[2]
Definition: event.c:4
static void get_event_details(int event, int *bit, char *name)
Definition: sock.c:5504
static NTSTATUS ( WINAPI pNtSetInformationFile)
static
static void ok_event_sequence ( SOCKET  s,
HANDLE  hEvent,
const LPARAM seq,
const LPARAM **  broken_seqs,
int  completelyBroken 
)
static

Definition at line 5688 of file sock.c.

5689 {
5690  MSG msg;
5691  WSANETWORKEVENTS events, *netEvents = NULL;
5692  int ret;
5693  DWORD dwRet;
5694 
5696  {
5697  netEvents = &events;
5698 
5699  dwRet = WaitForSingleObject(hEvent, 200);
5700  if (dwRet == WAIT_OBJECT_0)
5701  {
5702  ret = WSAEnumNetworkEvents(s, hEvent, netEvents);
5703  if (ret)
5704  {
5705  winetest_ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5706  return;
5707  }
5708  }
5709  else
5710  memset(netEvents, 0, sizeof(*netEvents));
5711  }
5712  else
5713  {
5714  Sleep(200);
5715  /* Run the message loop a little */
5716  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
5717  {
5718  DispatchMessageA(&msg);
5719  }
5720  }
5721 
5722  if (match_event_sequence(s, netEvents, seq))
5723  {
5724  winetest_ok(1, "Sequence matches expected: %s\n", dbgstr_event_seq(seq));
5725  flush_events(s, hEvent);
5726  return;
5727  }
5728 
5729  if (broken_seqs)
5730  {
5731  for (; *broken_seqs; broken_seqs++)
5732  {
5733  if (match_event_sequence(s, netEvents, *broken_seqs))
5734  {
5735  winetest_ok(broken(1), "Sequence matches broken: %s, expected %s\n", dbgstr_event_seq_result(s, netEvents), dbgstr_event_seq(seq));
5736  flush_events(s, hEvent);
5737  return;
5738  }
5739  }
5740  }
5741 
5742  winetest_ok(broken(completelyBroken), "Expected event sequence %s, got %s\n", dbgstr_event_seq(seq),
5743  dbgstr_event_seq_result(s, netEvents));
5744  flush_events(s, hEvent);
5745 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
static const char * dbgstr_event_seq(const LPARAM *seq)
Definition: sock.c:5538
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
DWORD DWORD
Definition: winlogon.h:75
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:557
#define WAIT_OBJECT_0
Definition: winbase.h:378
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
int ret
static char * dbgstr_event_seq_result(SOCKET s, WSANETWORKEVENTS *netEvents)
Definition: sock.c:5557
GLdouble s
Definition: gl.h:2039
#define broken(x)
Definition: _sntprintf.h:21
static void flush_events(SOCKET s, HANDLE hEvent)
Definition: sock.c:5601
HANDLE events[2]
Definition: event.c:4
#define msg(x)
Definition: auth_time.c:54
static int match_event_sequence(SOCKET s, WSANETWORKEVENTS *netEvents, const LPARAM *seq)
Definition: sock.c:5641
#define PM_REMOVE
Definition: winuser.h:1172
#define memset(x, y, z)
Definition: compat.h:39
static VOID WINAPI oob_client ( client_params par)
static

Definition at line 866 of file sock.c.

867 {
868  test_params *gen = par->general;
870  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
871 
872  id = GetCurrentThreadId();
873  trace ( "oob_client (%x): starting\n", id );
874  /* wait here because we want to call set_so_opentype before creating a socket */
876  trace ( "oob_client (%x): server ready\n", id );
877 
879  set_so_opentype ( FALSE ); /* non-overlapped */
880  client_start ( par );
881  mem = TlsGetValue ( tls );
882 
883  /* Connect */
884  wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
885  0 ==, "oob_client (%x): connect error: %d\n" );
886  ok ( set_blocking ( mem->s, TRUE ) == 0,
887  "oob_client (%x): failed to set blocking mode\n", id );
888  trace ( "oob_client (%x) connected\n", id );
889 
890  /* send data to server */
891  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
892  ok ( n_sent == n_expected,
893  "oob_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
894 
895  /* Receive data echoed back & check it */
896  n_recvd = do_synchronous_recv ( mem->s, mem->recv_buf, n_expected, 0, par->buflen );
897  ok ( n_recvd == n_expected,
898  "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
899  pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
900  ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
901 
902  /* send out-of-band data to server */
903  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, MSG_OOB, par->buflen );
904  ok ( n_sent == n_expected,
905  "oob_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
906 
907  /* shutdown send direction */
908  wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
909 
910  /* cleanup */
911  read_zero_bytes ( mem->s );
912  trace ( "oob_client (%x) exiting\n", id );
913  client_stop ();
914 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:143
char * recv_buf
Definition: sock.c:172
static void check_so_opentype(void)
Definition: sock.c:381
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
#define MSG_OOB
Definition: winsock.h:221
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
struct sockaddr_in addr
Definition: sock.c:170
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
SOCKET s
Definition: sock.c:169
int buflen
Definition: sock.c:145
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
static void read_zero_bytes(SOCKET s)
Definition: sock.c:329
static void client_start(client_params *par)
Definition: sock.c:511
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define SD_SEND
Definition: winsock.h:55
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:351
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
char * send_buf
Definition: sock.c:171
GLenum GLuint id
Definition: glext.h:5579
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:338
static HANDLE server_ready
Definition: sock.c:227
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:128
static void client_stop(void)
Definition: sock.c:538
static VOID WINAPI oob_server ( server_params par)
static

Definition at line 608 of file sock.c.

609 {
610  test_params *gen = par->general;
612  u_long atmark = 0;
613  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, tmp,
614  id = GetCurrentThreadId();
615 
616  trace ( "oob_server (%x) starting\n", id );
617 
618  set_so_opentype ( FALSE ); /* non-overlapped */
619  server_start ( par );
620  mem = TlsGetValue ( tls );
621 
622  wsa_ok ( set_blocking ( mem->s, TRUE ), 0 ==, "oob_server (%x): failed to set blocking mode: %d\n");
623  wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "oob_server (%x): listen failed: %d\n");
624 
625  trace ( "oob_server (%x) ready\n", id );
626  SetEvent ( server_ready ); /* notify clients */
627 
628  trace ( "oob_server (%x): waiting for client\n", id );
629 
630  /* accept a single connection */
631  tmp = sizeof ( mem->sock[0].peer );
632  mem->sock[0].s = accept ( mem->s, (struct sockaddr*) &mem->sock[0].peer, &tmp );
633  wsa_ok ( mem->sock[0].s, INVALID_SOCKET !=, "oob_server (%x): accept failed: %d\n" );
634 
635  ok ( mem->sock[0].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
636  "oob_server (%x): strange peer address\n", id );
637 
638  /* check initial atmark state */
639  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
640  ok ( atmark == 1, "oob_server (%x): unexpectedly at the OOB mark: %i\n", id, atmark );
641 
642  /* Receive normal data */
643  n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
644  ok ( n_recvd == n_expected,
645  "oob_server (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
646  pos = test_buffer ( mem->sock[0].buf, gen->chunk_size, gen->n_chunks );
647  ok ( pos == -1, "oob_server (%x): test pattern error: %d\n", id, pos);
648 
649  /* check atmark state */
650  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
651  ok ( atmark == 1, "oob_server (%x): unexpectedly at the OOB mark: %i\n", id, atmark );
652 
653  /* Echo data back */
654  n_sent = do_synchronous_send ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
655  ok ( n_sent == n_expected,
656  "oob_server (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
657 
658  /* Receive a part of the out-of-band data and print atmark state */
659  n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, 8, 0, par->buflen );
660  ok ( n_recvd == 8,
661  "oob_server (%x): received less data than expected: %d of %d\n", id, n_recvd, 8 );
662  n_expected -= 8;
663 
664  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
665  trace( "oob_server (%x): %s the OOB mark: %i\n", id, atmark == 1 ? "not at" : "at", atmark );
666 
667  /* Receive the rest of the out-of-band data and check atmark state */
668  do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
669 
670  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
671  todo_wine ok ( atmark == 0, "oob_server (%x): not at the OOB mark: %i\n", id, atmark );
672 
673  /* cleanup */
674  wsa_ok ( closesocket ( mem->sock[0].s ), 0 ==, "oob_server (%x): closesocket error: %d\n" );
675  mem->sock[0].s = INVALID_SOCKET;
676 
677  trace ( "oob_server (%x) exiting\n", id );
678  server_stop ();
679 }
#define trace(...)
Definition: kmt_test.h:172
#define SIOCATMARK
Definition: winsock.h:253
#define TRUE
Definition: types.h:120
unsigned long u_long
Definition: linux.h:269
#define inet_addr(cp)
Definition: inet.h:98
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
SOCKET s
Definition: sock.c:112
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
char * buf
Definition: sock.c:115
#define SOMAXCONN
Definition: winsock.h:399
#define closesocket
Definition: main.c:50
#define FALSE
Definition: types.h:117
static void server_start(server_params *par)
Definition: sock.c:466
SOCKET s
Definition: sock.c:161
test_params * general
Definition: sock.c:135
#define ioctlsocket
Definition: main.c:51
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define INVALID_SOCKET
Definition: winsock.h:332
const char * inet_addr
Definition: sock.c:125
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
#define todo_wine
Definition: test.h:154
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
int buflen
Definition: sock.c:137
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
struct sockaddr_in peer
Definition: sock.c:114
sock_info sock[MAX_CLIENTS]
Definition: sock.c:163
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:351
static void server_stop(void)
Definition: sock.c:493
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:338
static HANDLE server_ready
Definition: sock.c:227
int n_chunks
Definition: sock.c:128
static PCSTR ( WINAPI pInetNtop)
static
static PCWSTR ( WINAPI pInetNtopW)
static
static BOOL poll_isset ( WSAPOLLFD *  fds,
int  max,
SOCKET  s,
int  rev 
)
static

Definition at line 6903 of file sock.c.

6904 {
6905  int k;
6906  for (k = 0; k < max; k++)
6907  if (fds[k].fd == s && (fds[k].revents == rev)) return TRUE;
6908  return FALSE;
6909 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int rev
Definition: sort.c:17
GLdouble s
Definition: gl.h:2039
static HANDLE fd
Definition: io.c:55
int k
Definition: mpi.c:3369
static void read_zero_bytes ( SOCKET  s)
static

Definition at line 329 of file sock.c.

Referenced by oob_client(), select_server(), simple_client(), simple_mixed_client(), and simple_server().

330 {
331  char buf[256];
332  int tmp, n = 0;
333  while ( ( tmp = recv ( s, buf, 256, 0 ) ) > 0 )
334  n += tmp;
335  ok ( n <= 0, "garbage data received: %d bytes\n", n );
336 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint n
Definition: s_context.h:57
GLdouble s
Definition: gl.h:2039
#define ok(value,...)
Definition: CImage.cpp:33
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static DWORD WINAPI recv_thread ( LPVOID  arg)
static

Definition at line 6698 of file sock.c.

Referenced by test_WSARecv().

6699 {
6700  SOCKET sock = *(SOCKET *)arg;
6701  char buffer[32];
6702  WSABUF wsa;
6703  WSAOVERLAPPED ov;
6704  DWORD flags = 0;
6705 
6706  wsa.buf = buffer;
6707  wsa.len = sizeof(buffer);
6708  ov.hEvent = WSACreateEvent();
6709  WSARecv(sock, &wsa, 1, NULL, &flags, &ov, NULL);
6710 
6711  WaitForSingleObject(ov.hEvent, 1000);
6712  WSACloseEvent(ov.hEvent);
6713  return 0;
6714 }
GLuint buffer
Definition: glext.h:5915
DWORD DWORD
Definition: winlogon.h:75
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WSAAPI WSACloseEvent(IN WSAEVENT hEvent)
Definition: event.c:23
smooth NULL
Definition: ftsmooth.c:557
ULONG len
Definition: ws2def.h:519
GLbitfield flags
Definition: glext.h:7161
CHAR FAR * buf
Definition: ws2def.h:520
INT WSAAPI WSARecv(IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: recv.c:155
WSAEVENT WSAAPI WSACreateEvent(VOID)
Definition: event.c:42
#define WSAOVERLAPPED
Definition: winsock2.h:587
Definition: tcpcore.h:1455
UINT_PTR SOCKET
Definition: winsock.h:47
static VOID WINAPI select_server ( server_params par)
static

Definition at line 684 of file sock.c.

685 {
686  test_params *gen = par->general;
688  int n_expected = gen->n_chunks * gen->chunk_size, tmp, i,
689  id = GetCurrentThreadId(), n_connections = 0, n_sent, n_recvd,
690  n_set, delta, n_ready;
691  struct timeval timeout = {0,10}; /* wait for 10 milliseconds */
692  fd_set fds_recv, fds_send, fds_openrecv, fds_opensend;
693 
694  trace ( "select_server (%x) starting\n", id );
695 
696  set_so_opentype ( FALSE ); /* non-overlapped */
697  server_start ( par );
698  mem = TlsGetValue ( tls );
699 
700  wsa_ok ( set_blocking ( mem->s, FALSE ), 0 ==, "select_server (%x): failed to set blocking mode: %d\n");
701  wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "select_server (%x): listen failed: %d\n");
702 
703  trace ( "select_server (%x) ready\n", id );
704  SetEvent ( server_ready ); /* notify clients */
705 
706  FD_ZERO ( &fds_openrecv );
707  FD_ZERO ( &fds_recv );
708  FD_ZERO ( &fds_send );
709  FD_ZERO ( &fds_opensend );
710 
711  FD_SET ( mem->s, &fds_openrecv );
712 
713  while(1)
714  {
715  fds_recv = fds_openrecv;
716  fds_send = fds_opensend;
717 
718  n_set = 0;
719 
720  wsa_ok ( ( n_ready = select ( 0, &fds_recv, &fds_send, NULL, &timeout ) ), SOCKET_ERROR !=,
721  "select_server (%x): select() failed: %d\n" );
722 
723  /* check for incoming requests */
724  if ( FD_ISSET ( mem->s, &fds_recv ) ) {
725  n_set += 1;
726 
727  trace ( "select_server (%x): accepting client connection\n", id );
728 
729  /* accept a single connection */
730  tmp = sizeof ( mem->sock[n_connections].peer );
731  mem->sock[n_connections].s = accept ( mem->s, (struct sockaddr*) &mem->sock[n_connections].peer, &tmp );
732  wsa_ok ( mem->sock[n_connections].s, INVALID_SOCKET !=, "select_server (%x): accept() failed: %d\n" );
733 
734  ok ( mem->sock[n_connections].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
735  "select_server (%x): strange peer address\n", id );
736 
737  /* add to list of open connections */
738  FD_SET ( mem->sock[n_connections].s, &fds_openrecv );
739  FD_SET ( mem->sock[n_connections].s, &fds_opensend );
740 
741  n_connections++;
742  }
743 
744  /* handle open requests */
745 
746  for ( i = 0; i < n_connections; i++ )
747  {
748  if ( FD_ISSET( mem->sock[i].s, &fds_recv ) ) {
749  n_set += 1;
750 
751  if ( mem->sock[i].n_recvd < n_expected ) {
752  /* Receive data & check it */
753  n_recvd = recv ( mem->sock[i].s, mem->sock[i].buf + mem->sock[i].n_recvd, min ( n_expected - mem->sock[i].n_recvd, par->buflen ), 0 );
754  ok ( n_recvd != SOCKET_ERROR, "select_server (%x): error in recv(): %d\n", id, WSAGetLastError() );
755  mem->sock[i].n_recvd += n_recvd;
756 
757  if ( mem->sock[i].n_recvd == n_expected ) {
758  int pos = test_buffer ( mem->sock[i].buf, gen->chunk_size, gen->n_chunks );
759  ok ( pos == -1, "select_server (%x): test pattern error: %d\n", id, pos );
760  FD_CLR ( mem->sock[i].s, &fds_openrecv );
761  }
762 
763  ok ( mem->sock[i].n_recvd <= n_expected, "select_server (%x): received too many bytes: %d\n", id, mem->sock[i].n_recvd );
764  }
765  }
766 
767  /* only echo back what we've received */
768  delta = mem->sock[i].n_recvd - mem->sock[i].n_sent;
769 
770  if ( FD_ISSET ( mem->sock[i].s, &fds_send ) ) {
771  n_set += 1;
772 
773  if ( ( delta > 0 ) && ( mem->sock[i].n_sent < n_expected ) ) {
774  /* Echo data back */
775  n_sent = send ( mem->sock[i].s, mem->sock[i].buf + mem->sock[i].n_sent, min ( delta, par->buflen ), 0 );
776  ok ( n_sent != SOCKET_ERROR, "select_server (%x): error in send(): %d\n", id, WSAGetLastError() );
777  mem->sock[i].n_sent += n_sent;
778 
779  if ( mem->sock[i].n_sent == n_expected ) {
780  FD_CLR ( mem->sock[i].s, &fds_opensend );
781  }
782 
783  ok ( mem->sock[i].n_sent <= n_expected, "select_server (%x): sent too many bytes: %d\n", id, mem->sock[i].n_sent );
784  }
785  }
786  }
787 
788  /* check that select returned the correct number of ready sockets */
789  ok ( ( n_set == n_ready ), "select_server (%x): select() returns wrong number of ready sockets\n", id );
790 
791  /* check if all clients are done */
792  if ( ( fds_opensend.fd_count == 0 )
793  && ( fds_openrecv.fd_count == 1 ) /* initial socket that accepts clients */
794  && ( n_connections == min ( gen->n_clients, MAX_CLIENTS ) ) ) {
795  break;
796  }
797  }
798 
799  for ( i = 0; i < min ( gen->n_clients, MAX_CLIENTS ); i++ )
800  {
801  /* cleanup */
802  read_zero_bytes ( mem->sock[i].s );
803  wsa_ok ( closesocket ( mem->sock[i].s ), 0 ==, "select_server (%x): closesocket error: %d\n" );
804  mem->sock[i].s = INVALID_SOCKET;
805  }
806 
807  trace ( "select_server (%x) exiting\n", id );
808  server_stop ();
809 }
Definition: winsock.h:66
#define SOCKET_ERROR
Definition: winsock.h:333
#define trace(...)
Definition: kmt_test.h:172
#define inet_addr(cp)
Definition: inet.h:98
int n_recvd
Definition: sock.c:116
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
SOCKET s
Definition: sock.c:112
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
Definition: dhcpd.h:245
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
u_int fd_count
Definition: winsock.h:67
char * buf
Definition: sock.c:115
int n_sent
Definition: sock.c:117
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define SOMAXCONN
Definition: winsock.h:399
#define closesocket
Definition: main.c:50
#define FALSE
Definition: types.h:117
#define FD_ISSET(fd, set)
Definition: winsock.h:100
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
static void server_start(server_params *par)
Definition: sock.c:466
SOCKET s
Definition: sock.c:161
smooth NULL
Definition: ftsmooth.c:557
test_params * general
Definition: sock.c:135
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define MAX_CLIENTS
Definition: sock.c:43
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define INVALID_SOCKET
Definition: winsock.h:332
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
const char * inet_addr
Definition: sock.c:125
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
static void read_zero_bytes(SOCKET s)
Definition: sock.c:329
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
int buflen
Definition: sock.c:137
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
struct sockaddr_in peer
Definition: sock.c:114
int n_clients
Definition: sock.c:129
sock_info sock[MAX_CLIENTS]
Definition: sock.c:163
#define min(a, b)
Definition: monoChain.cc:55
static void server_stop(void)
Definition: sock.c:493
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
#define FD_CLR(fd, set)
Definition: winsock.h:74
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static HANDLE server_ready
Definition: sock.c:227
int n_chunks
Definition: sock.c:128
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
static DWORD WINAPI SelectCloseThread ( void param)
static

Definition at line 3644 of file sock.c.

Referenced by test_select(), and test_WSAPoll().

3645 {
3646  SOCKET s = *(SOCKET*)param;
3647  Sleep(500);
3648  closesocket(s);
3649  return 0;
3650 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define closesocket
Definition: main.c:50
GLdouble s
Definition: gl.h:2039
UINT_PTR SOCKET
Definition: winsock.h:47
static DWORD WINAPI SelectReadThread ( void param)
static

Definition at line 3617 of file sock.c.

Referenced by test_select().

3618 {
3619  select_thread_params *par = param;
3620  fd_set readfds;
3621  int ret;
3622  struct sockaddr_in addr;
3623  struct timeval select_timeout;
3624 
3625  memset(&readfds, 0, sizeof(readfds));
3626  FD_ZERO(&readfds);
3627  FD_SET(par->s, &readfds);
3628  select_timeout.tv_sec=5;
3629  select_timeout.tv_usec=0;
3630  addr.sin_family = AF_INET;
3631  addr.sin_addr.s_addr = inet_addr(SERVERIP);
3632  addr.sin_port = htons(SERVERPORT);
3633 
3634  do_bind(par->s, (struct sockaddr *)&addr, sizeof(addr));
3635  wsa_ok(listen(par->s, SOMAXCONN ), 0 ==, "SelectReadThread (%x): listen failed: %d\n");
3636 
3638  ret = select(par->s+1, &readfds, NULL, NULL, &select_timeout);
3639  par->ReadKilled = (ret == 1);
3640 
3641  return 0;
3642 }
Definition: winsock.h:66
#define inet_addr(cp)
Definition: inet.h:98
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
#define SOMAXCONN
Definition: winsock.h:399
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
smooth NULL
Definition: ftsmooth.c:557
GLfloat param
Definition: glext.h:5796
#define SERVERPORT
Definition: sock.c:56
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
static void do_bind(SOCKET s, struct sockaddr *addr, int addrlen)
Definition: sock.c:452
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define AF_INET
Definition: tcpip.h:117
#define SERVERIP
Definition: sock.c:55
static HANDLE server_ready
Definition: sock.c:227
#define htons(x)
Definition: module.h:213
#define memset(x, y, z)
Definition: compat.h:39
static void server_start ( server_params par)
static

Definition at line 466 of file sock.c.

Referenced by nfs41_lookup(), oob_server(), select_server(), and simple_server().

467 {
468  int i;
469  test_params *gen = par->general;
470  server_memory *mem = LocalAlloc ( LPTR, sizeof ( server_memory ) );
471 
472  TlsSetValue ( tls, mem );
473  mem->s = WSASocketA ( AF_INET, gen->sock_type, gen->sock_prot,
474  NULL, 0, par->sock_flags );
475  ok ( mem->s != INVALID_SOCKET, "Server: WSASocket failed\n" );
476 
477  mem->addr.sin_family = AF_INET;
478  mem->addr.sin_addr.s_addr = inet_addr ( gen->inet_addr );
479  mem->addr.sin_port = htons ( gen->inet_port );
480 
481  for (i = 0; i < MAX_CLIENTS; i++)
482  {
483  mem->sock[i].s = INVALID_SOCKET;
484  mem->sock[i].buf = LocalAlloc ( LPTR, gen->n_chunks * gen->chunk_size );
485  mem->sock[i].n_recvd = 0;
486  mem->sock[i].n_sent = 0;
487  }
488 
489  if ( gen->sock_type == SOCK_STREAM )
490  do_bind ( mem->s, (struct sockaddr*) &mem->addr, sizeof (mem->addr) );
491 }
#define inet_addr(cp)
Definition: inet.h:98
int n_recvd
Definition: sock.c:116
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1221
SOCKET s
Definition: sock.c:112
SOCKET WSAAPI WSASocketA(IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOA lpProtocolInfo, IN GROUP g, IN DWORD dwFlags)
Definition: socklife.c:444
char * buf
Definition: sock.c:115
int n_sent
Definition: sock.c:117
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int sock_prot
Definition: sock.c:124
SOCKET s
Definition: sock.c:161
smooth NULL
Definition: ftsmooth.c:557
test_params * general
Definition: sock.c:135
int sock_type
Definition: sock.c:123
#define MAX_CLIENTS
Definition: sock.c:43
#define INVALID_SOCKET
Definition: winsock.h:332
const char * inet_addr
Definition: sock.c:125
short inet_port
Definition: sock.c:126
static void do_bind(SOCKET s, struct sockaddr *addr, int addrlen)
Definition: sock.c:452
sock_info sock[MAX_CLIENTS]
Definition: sock.c:163
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
#define AF_INET
Definition: tcpip.h:117
#define LPTR
Definition: winbase.h:353
struct sockaddr_in addr
Definition: sock.c:162
#define ok(value,...)
Definition: CImage.cpp:33
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
static DWORD tls
Definition: sock.c:224
#define SOCK_STREAM
Definition: tcpip.h:118
#define htons(x)
Definition: module.h:213
int n_chunks
Definition: sock.c:128
DWORD sock_flags
Definition: sock.c:136
static void server_stop ( void  )
static

Definition at line 493 of file sock.c.

Referenced by oob_server(), select_server(), and simple_server().

494 {
495  int i;
497 
498  for (i = 0; i < MAX_CLIENTS; i++ )
499  {
500  LocalFree ( mem->sock[i].buf );
501  if ( mem->sock[i].s != INVALID_SOCKET )
502  closesocket ( mem->sock[i].s );
503  }
504  ok ( closesocket ( mem->s ) == 0, "closesocket failed\n" );
505  LocalFree ( mem );
507 }
SOCKET s
Definition: sock.c:112
char * buf
Definition: sock.c:115
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define closesocket
Definition: main.c:50
SOCKET s
Definition: sock.c:161
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:349
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define MAX_CLIENTS
Definition: sock.c:43
#define INVALID_SOCKET
Definition: winsock.h:332
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
sock_info sock[MAX_CLIENTS]
Definition: sock.c:163
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int set_blocking ( SOCKET  s,
BOOL  blocking 
)
static
static void set_so_opentype ( BOOL  overlapped)
static

Definition at line 287 of file sock.c.

Referenced by oob_client(), oob_server(), select_server(), simple_client(), simple_mixed_client(), and simple_server().

288 {
289  int optval = !overlapped, newval, len = sizeof (int);
290 
292  (LPVOID) &optval, sizeof (optval) ) == 0,
293  "setting SO_OPENTYPE failed\n" );
295  (LPVOID) &newval, &len ) == 0,
296  "getting SO_OPENTYPE failed\n" );
297  ok ( optval == newval, "failed to set SO_OPENTYPE\n" );
298 }
#define SOL_SOCKET
Definition: winsock.h:398
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
#define INVALID_SOCKET
Definition: winsock.h:332
GLenum GLsizei len
Definition: glext.h:6722
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:79
#define SO_OPENTYPE
Definition: ws2_32.h:40
#define ok(value,...)
Definition: CImage.cpp:33
static int(WINAPI *pgetaddrinfo)(LPCSTR
static SOCKET setup_connector_socket ( struct sockaddr_in addr,
int  len,
BOOL  nonblock 
)
static

Definition at line 4228 of file sock.c.

Referenced by test_accept(), test_select(), and test_WSAPoll().

4229 {
4230  int ret;
4231  SOCKET connector;
4232 
4233  connector = socket(AF_INET, SOCK_STREAM, 0);
4234  ok(connector != INVALID_SOCKET, "failed to create connector socket %d\n", WSAGetLastError());
4235 
4236  if (nonblock)
4237  set_blocking(connector, !nonblock);
4238 
4239  ret = connect(connector, (struct sockaddr *)addr, len);
4240  if (!nonblock)
4241  ok(!ret, "connecting to accepting socket failed %d\n", WSAGetLastError());
4242  else if (ret == SOCKET_ERROR)
4243  {
4245  ok(error == WSAEWOULDBLOCK || error == WSAEINPROGRESS,
4246  "expected 10035 or 10036, got %d\n", error);
4247  }
4248 
4249  return connector;
4250 }
#define SOCKET_ERROR
Definition: winsock.h:333
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define WSAEINPROGRESS
Definition: winerror.h:1949
DWORD DWORD
Definition: winlogon.h:75
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define INVALID_SOCKET
Definition: winsock.h:332
static int nonblock(int fd, int isnonblock)
Definition: adnsresfilter.c:86
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define AF_INET
Definition: tcpip.h:117
#define ok(value,...)
Definition: CImage.cpp:33
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCK_STREAM
Definition: tcpip.h:118
static SOCKET setup_iocp_src ( struct sockaddr_in bindAddress)
static

Definition at line 9386 of file sock.c.

Referenced by test_completion_port().

9387 {
9389  int iret, socklen;
9390 
9391  src = socket(AF_INET, SOCK_STREAM, 0);
9392  if (src == INVALID_SOCKET)
9393  {
9394  skip("could not create listener socket, error %d\n", WSAGetLastError());
9395  goto end;
9396  }
9397 
9398  memset(bindAddress, 0, sizeof(*bindAddress));
9399  bindAddress->sin_family = AF_INET;
9400  bindAddress->sin_addr.s_addr = inet_addr("127.0.0.1");
9401  iret = bind(src, (struct sockaddr*)bindAddress, sizeof(*bindAddress));
9402  if (iret != 0)
9403  {
9404  skip("failed to bind, error %d\n", WSAGetLastError());
9405  goto end;
9406  }
9407 
9408  socklen = sizeof(*bindAddress);
9409  iret = getsockname(src, (struct sockaddr*)bindAddress, &socklen);
9410  if (iret != 0) {
9411  skip("failed to lookup bind address, error %d\n", WSAGetLastError());
9412  goto end;
9413  }
9414 
9415  if (set_blocking(src, FALSE))
9416  {
9417  skip("couldn't make socket non-blocking, error %d\n", WSAGetLastError());
9418  goto end;
9419  }
9420 
9421  iret = listen(src, 5);
9422  if (iret != 0)
9423  {
9424  skip("listening failed, errno = %d\n", WSAGetLastError());
9425  goto end;
9426  }
9427 
9428  ret = src;
9429 end:
9430  if (src != ret && ret == INVALID_SOCKET)
9431  closesocket(src);
9432  return ret;
9433 }
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define inet_addr(cp)
Definition: inet.h:98
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
GLuint GLuint end
Definition: gl.h:1545
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
#define closesocket
Definition: main.c:50
#define FALSE
Definition: types.h:117
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define INVALID_SOCKET
Definition: winsock.h:332
int ret
struct in_addr sin_addr
Definition: winsock.h:512
#define skip(...)
Definition: CString.cpp:57
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define AF_INET
Definition: tcpip.h:117
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCK_STREAM
Definition: tcpip.h:118
#define memset(x, y, z)
Definition: compat.h:39
short sin_family
Definition: winsock.h:510
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
static SOCKET setup_server_socket ( struct sockaddr_in addr,
int len 
)
static

Definition at line 4182 of file sock.c.

Referenced by test_accept(), test_select(), and test_WSAPoll().

4183 {
4184  int ret, val;
4186 
4187  server_socket = socket(AF_INET, SOCK_STREAM, 0);
4188  if (server_socket == INVALID_SOCKET)
4189  {
4190  trace("error creating server socket: %d\n", WSAGetLastError());
4191  return INVALID_SOCKET;
4192  }
4193 
4194  val = 1;
4195  ret = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
4196  if (ret)
4197  {
4198  trace("error setting SO_REUSEADDR: %d\n", WSAGetLastError());
4199  closesocket(server_socket);
4200  return INVALID_SOCKET;
4201  }
4202 
4203  ret = bind(server_socket, (struct sockaddr *)addr, *len);
4204  if (ret)
4205  {
4206  trace("error binding server socket: %d\n", WSAGetLastError());
4207  }
4208 
4209  ret = getsockname(server_socket, (struct sockaddr *)addr, len);
4210  if (ret)
4211  {
4212  skip("failed to lookup bind address: %d\n", WSAGetLastError());
4213  closesocket(server_socket);
4214  return INVALID_SOCKET;
4215  }
4216 
4217  ret = listen(server_socket, 5);
4218  if (ret)
4219  {
4220  trace("error making server socket listen: %d\n", WSAGetLastError());
4221  closesocket(server_socket);
4222  return INVALID_SOCKET;
4223  }
4224 
4225  return server_socket;
4226 }
#define trace(...)
Definition: kmt_test.h:172
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define SOL_SOCKET
Definition: winsock.h:398
#define closesocket
Definition: main.c:50
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
#define SO_REUSEADDR
Definition: winsock.h:180
GLuint GLfloat * val
Definition: glext.h:7180
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define INVALID_SOCKET
Definition: winsock.h:332
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define skip(...)
Definition: CString.cpp:57
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define AF_INET
Definition: tcpip.h:117
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCK_STREAM
Definition: tcpip.h:118
static int server_socket
Definition: notification.c:641
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
static VOID WINAPI simple_client ( client_params par)
static

Definition at line 816 of file sock.c.

817 {
818  test_params *gen = par->general;
820  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
821 
822  id = GetCurrentThreadId();
823  trace ( "simple_client (%x): starting\n", id );
824  /* wait here because we want to call set_so_opentype before creating a socket */
826  trace ( "simple_client (%x): server ready\n", id );
827 
829  set_so_opentype ( FALSE ); /* non-overlapped */
830  client_start ( par );
831  mem = TlsGetValue ( tls );
832 
833  /* Connect */
834  wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
835  0 ==, "simple_client (%x): connect error: %d\n" );
836  ok ( set_blocking ( mem->s, TRUE ) == 0,
837  "simple_client (%x): failed to set blocking mode\n", id );
838  trace ( "simple_client (%x) connected\n", id );
839 
840  /* send data to server */
841  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
842  ok ( n_sent == n_expected,
843  "simple_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
844 
845  /* shutdown send direction */
846  wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
847 
848  /* Receive data echoed back & check it */
849  n_recvd = do_synchronous_recv ( mem->s, mem->recv_buf, n_expected, 0, par->buflen );
850  ok ( n_recvd == n_expected,
851  "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
852 
853  /* check data */
854  pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
855  ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
856 
857  /* cleanup */
858  read_zero_bytes ( mem->s );
859  trace ( "simple_client (%x) exiting\n", id );
860  client_stop ();
861 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:143
char * recv_buf
Definition: sock.c:172
static void check_so_opentype(void)
Definition: sock.c:381
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
struct sockaddr_in addr
Definition: sock.c:170
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
SOCKET s
Definition: sock.c:169
int buflen
Definition: sock.c:145
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
static void read_zero_bytes(SOCKET s)
Definition: sock.c:329
static void client_start(client_params *par)
Definition: sock.c:511
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define SD_SEND
Definition: winsock.h:55
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:351
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
char * send_buf
Definition: sock.c:171
GLenum GLuint id
Definition: glext.h:5579
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:338
static HANDLE server_ready
Definition: sock.c:227
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:128
static void client_stop(void)
Definition: sock.c:538
static VOID WINAPI simple_mixed_client ( client_params par)
static

Definition at line 919 of file sock.c.

920 {
921  test_params *gen = par->general;
923  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
924  int fromLen = sizeof(mem->addr);
925  struct sockaddr test;
926 
927  id = GetCurrentThreadId();
928  trace ( "simple_client (%x): starting\n", id );
929  /* wait here because we want to call set_so_opentype before creating a socket */
931  trace ( "simple_client (%x): server ready\n", id );
932 
934  set_so_opentype ( FALSE ); /* non-overlapped */
935  client_start ( par );
936  mem = TlsGetValue ( tls );
937 
938  /* Connect */
939  wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
940  0 ==, "simple_client (%x): connect error: %d\n" );
941  ok ( set_blocking ( mem->s, TRUE ) == 0,
942  "simple_client (%x): failed to set blocking mode\n", id );
943  trace ( "simple_client (%x) connected\n", id );
944 
945  /* send data to server */
946  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
947  ok ( n_sent == n_expected,
948  "simple_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
949 
950  /* shutdown send direction */
951  wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
952 
953  /* this shouldn't change, since lpFrom, is not updated on
954  connection oriented sockets - exposed by bug 11640
955  */
956  ((struct sockaddr_in*)&test)->sin_addr.s_addr = inet_addr("0.0.0.0");
957 
958  /* Receive data echoed back & check it */
959  n_recvd = do_synchronous_recvfrom ( mem->s,
960  mem->recv_buf,
961  n_expected,
962  0,
963  (struct sockaddr *)&test,
964  &fromLen,
965  par->buflen );
966  ok ( n_recvd == n_expected,
967  "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
968 
969  /* check that lpFrom was not updated */
970  ok(0 ==
971  strcmp(
972  inet_ntoa(((struct sockaddr_in*)&test)->sin_addr),
973  "0.0.0.0"), "lpFrom shouldn't be updated on connection oriented sockets\n");
974 
975  /* check data */
976  pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
977  ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
978 
979  /* cleanup */
980  read_zero_bytes ( mem->s );
981  trace ( "simple_client (%x) exiting\n", id );
982  client_stop ();
983 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:143
static int do_synchronous_recvfrom(SOCKET s, char *buf, int buflen, int flags, struct sockaddr *from, int *fromlen, int recvlen)
Definition: sock.c:364
char * recv_buf
Definition: sock.c:172
static void check_so_opentype(void)
Definition: sock.c:381
#define inet_addr(cp)
Definition: inet.h:98
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
#define test
Definition: rosglue.h:37
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define inet_ntoa(addr)
Definition: inet.h:100
struct sockaddr_in addr
Definition: sock.c:170
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
SOCKET s
Definition: sock.c:169
int buflen
Definition: sock.c:145
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
static void read_zero_bytes(SOCKET s)
Definition: sock.c:329
static void client_start(client_params *par)
Definition: sock.c:511
struct in_addr sin_addr
Definition: winsock.h:512
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
#define SD_SEND
Definition: winsock.h:55
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
char * send_buf
Definition: sock.c:171
GLenum GLuint id
Definition: glext.h:5579
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:338
static HANDLE server_ready
Definition: sock.c:227
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:128
static void client_stop(void)
Definition: sock.c:538
static VOID WINAPI simple_server ( server_params par)
static

Definition at line 552 of file sock.c.

553 {
554  test_params *gen = par->general;
556  int pos, n_recvd, n_sent, n_expected = gen->n_chunks * gen->chunk_size, tmp, i,
557  id = GetCurrentThreadId();
558 
559  trace ( "simple_server (%x) starting\n", id );
560 
561  set_so_opentype ( FALSE ); /* non-overlapped */
562  server_start ( par );
563  mem = TlsGetValue ( tls );
564 
565  wsa_ok ( set_blocking ( mem->s, TRUE ), 0 ==, "simple_server (%x): failed to set blocking mode: %d\n");
566  wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "simple_server (%x): listen failed: %d\n");
567 
568  trace ( "simple_server (%x) ready\n", id );
569  SetEvent ( server_ready ); /* notify clients */
570 
571  for ( i = 0; i < min ( gen->n_clients, MAX_CLIENTS ); i++ )
572  {
573  trace ( "simple_server (%x): waiting for client\n", id );
574 
575  /* accept a single connection */
576  tmp = sizeof ( mem->sock[0].peer );
577  mem->sock[0].s = accept ( mem->s, (struct sockaddr*) &mem->sock[0].peer, &tmp );
578  wsa_ok ( mem->sock[0].s, INVALID_SOCKET !=, "simple_server (%x): accept failed: %d\n" );
579 
580  ok ( mem->sock[0].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
581  "simple_server (%x): strange peer address\n", id );
582 
583  /* Receive data & check it */
584  n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
585  ok ( n_recvd == n_expected,
586  "simple_server (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
587  pos = test_buffer ( mem->sock[0].buf, gen->chunk_size, gen->n_chunks );
588  ok ( pos == -1, "simple_server (%x): test pattern error: %d\n", id, pos);
589 
590  /* Echo data back */
591  n_sent = do_synchronous_send ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
592  ok ( n_sent == n_expected,
593  "simple_server (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
594 
595  /* cleanup */
596  read_zero_bytes ( mem->sock[0].s );
597  wsa_ok ( closesocket ( mem->sock[0].s ), 0 ==, "simple_server (%x): closesocket error: %d\n" );
598  mem->sock[0].s = INVALID_SOCKET;
599  }
600 
601  trace ( "simple_server (%x) exiting\n", id );
602  server_stop ();
603 }
#define trace(...)
Definition: kmt_test.h:172
#define TRUE
Definition: types.h:120
#define inet_addr(cp)
Definition: inet.h:98
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:300
SOCKET s
Definition: sock.c:112
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
char * buf
Definition: sock.c:115
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define SOMAXCONN
Definition: winsock.h:399
#define closesocket
Definition: main.c:50
#define FALSE
Definition: types.h:117
static void server_start(server_params *par)
Definition: sock.c:466
SOCKET s
Definition: sock.c:161
test_params * general
Definition: sock.c:135
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:443
#define MAX_CLIENTS
Definition: sock.c:43
#define INVALID_SOCKET
Definition: winsock.h:332
const char * inet_addr
Definition: sock.c:125
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:287
static void read_zero_bytes(SOCKET s)
Definition: sock.c:329
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
int buflen
Definition: sock.c:137
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:313
#define wsa_ok(op, cond, msg)
Definition: sock.c:58
struct sockaddr_in peer
Definition: sock.c:114
int n_clients
Definition: sock.c:129
sock_info sock[MAX_CLIENTS]
Definition: sock.c:163
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:351
#define min(a, b)
Definition: monoChain.cc:55
static void server_stop(void)
Definition: sock.c:493
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1185
Definition: mem.c:156
int chunk_size
Definition: sock.c:127
#define ok(value,...)
Definition: CImage.cpp:33
static DWORD tls
Definition: sock.c:224
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:338
static HANDLE server_ready
Definition: sock.c:227
int n_chunks
Definition: sock.c:128
START_TEST ( sock  )

Definition at line 10703 of file sock.c.

10704 {
10705  int i;
10706 
10707 /* Leave these tests at the beginning. They depend on WSAStartup not having been
10708  * called, which is done by Init() below. */
10711 
10712  Init();
10713 
10714  test_inet_ntoa();
10715  test_inet_pton();
10718  test_ip_pktinfo();
10720 
10721  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
10722  {
10723  trace ( " **** STARTING TEST %d ****\n", i );
10724  do_test ( &tests[i] );
10725  trace ( " **** TEST %d COMPLETE ****\n", i );
10726  }
10727 
10728  test_UDP();
10729 
10731  test_WSASocket();
10734 
10737 
10740 
10741  test_errors();
10742  test_listen();
10743  test_select();
10744  test_accept();
10745  test_getpeername();
10746  test_getsockname();
10747  test_inet_addr();
10749  test_ioctlsocket();
10750  test_dns();
10753  test_gethostname();
10754 
10755  test_WSASendMsg();
10756  test_WSASendTo();
10757  test_WSARecv();
10758  test_WSAPoll();
10759 
10760  test_events(0);
10761  test_events(1);
10762 
10763  test_ipv6only();
10767  test_getaddrinfo();
10768  test_AcceptEx();
10769  test_ConnectEx();
10771 
10774 
10778 
10781 
10784 
10785  /* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
10786  test_send();
10788 
10789  Exit();
10790 }
static void test_WSARecv(void)
Definition: sock.c:6723
#define trace(...)
Definition: kmt_test.h:172
static void test_WithWSAStartup(void)
Definition: sock.c:1130
static void test_WSAAddressToStringA(void)
Definition: sock.c:2981
static void test_TransmitFile(void)
Definition: sock.c:8617
static void test_gethostbyname(void)
Definition: sock.c:4680
static void test_addr_to_print(void)
Definition: sock.c:4874
static void test_WSAAsyncGetServByName(void)
Definition: sock.c:9352
static void test_listen(void)
Definition: sock.c:3689
static void test_set_getsockopt(void)
Definition: sock.c:1351
static void test_getservbyname(void)
Definition: sock.c:2333
static void test_WSAAsyncGetServByPort(void)
Definition: sock.c:9322
static void test_address_list_query(void)
Definition: sock.c:10262
static void test_ip_pktinfo(void)
Definition: sock.c:1948
static void test_getaddrinfo(void)
Definition: sock.c:7506
static void test_gethostname(void)
Definition: sock.c:4833
static void test_WSAAddressToStringW(void)
Definition: sock.c:3164
static void test_DisconnectEx(void)
Definition: sock.c:8495
static void test_inet_addr(void)
Definition: sock.c:4866
static void test_WSAStringToAddressA(void)
Definition: sock.c:3353
static test_setup tests[]
Definition: sock.c:2135
static void test_inet_pton(void)
Definition: sock.c:5005
static void test_extendedSocketOptions(void)
Definition: sock.c:4415
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static void test_so_reuseaddr(void)
Definition: sock.c:1869
static void test_WSADuplicateSocket(void)
Definition: sock.c:2740
static void test_WSASendTo(void)
Definition: sock.c:6659
static void test_UDP(void)
Definition: sock.c:2244
static void test_completion_port(void)
Definition: sock.c:9435
static void test_dns(void)
Definition: sock.c:4624
static void test_WSAEnumNameSpaceProvidersW(void)
Definition: sock.c:10616
static void test_select(void)
Definition: sock.c:3776
static void Init(void)
Definition: sock.c:1233
static void test_events(int useMessages)
Definition: sock.c:5749
static void test_ipv6only(void)
Definition: sock.c:6325
static void test_synchronous_WSAIoctl(void)
Definition: sock.c:9239
static void Exit(void)
Definition: sock.c:1272
static void test_WSAStringToAddressW(void)
Definition: sock.c:3477
static void test_gethostbyname_hack(void)
Definition: sock.c:4776
static void test_ConnectEx(void)
Definition: sock.c:7775
static void test_WSASocket(void)
Definition: sock.c:2354
static void test_getpeername(void)
Definition: sock.c:8850
static void test_WSALookupService(void)
Definition: sock.c:10370
static void test_WSAPoll(void)
Definition: sock.c:6911
static void test_inet_ntoa(void)
Definition: sock.c:10342
static void test_getsockname(void)
Definition: sock.c:4532
static void test_WSASendMsg(void)
Definition: sock.c:6474
static void test_AcceptEx(void)
Definition: sock.c:7986
static void test_WSAEnumNetworkEvents(void)
Definition: sock.c:2901
static void do_test(test_setup *test)
Definition: sock.c:1304
static void test_WSAEnumNameSpaceProvidersA(void)
Definition: sock.c:10531
static void test_sioRoutingInterfaceQuery(void)
Definition: sock.c:8942
static void test_sioAddressListChange(void)
Definition: sock.c:9003
static void test_GetAddrInfoW(void)
Definition: sock.c:7121
static void test_send(void)
Definition: sock.c:5327
static void test_accept(void)
Definition: sock.c:4252
static void test_WithoutWSAStartup(void)
Definition: sock.c:1115
static void test_errors(void)
Definition: sock.c:3652
static void test_GetAddrInfoExW(void)
Definition: sock.c:7394
static void test_ioctlsocket(void)
Definition: sock.c:5150
static void StartClients ( LPTHREAD_START_ROUTINE  routine,
test_params general,
client_params par 
)
static

Definition at line 1289 of file sock.c.

Referenced by do_test().

1291 {
1292  int i;
1293  par->general = general;
1294  for ( i = 1; i <= min ( general->n_clients, MAX_CLIENTS ); i++ )
1295  {
1296  client_id = i - 1;
1297  thread[i] = CreateThread ( NULL, 0, routine, par, 0, &thread_id[i] );
1298  ok ( thread[i] != NULL, "Failed to create client thread\n" );
1299  /* Make sure the client is up and running */
1301  };
1302 }
test_params * general
Definition: sock.c:143
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:225
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static int client_id
Definition: sock.c:229
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:135
smooth NULL
Definition: ftsmooth.c:557
#define MAX_CLIENTS
Definition: sock.c:43
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:226
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:228
int jpeg_marker_parser_method routine
Definition: jpeglib.h:1089
int n_clients
Definition: sock.c:129
#define min(a, b)
Definition: monoChain.cc:55
#define ok(value,...)
Definition: CImage.cpp:33
#define INFINITE
Definition: serial.h:102
static void StartServer ( LPTHREAD_START_ROUTINE  routine,
test_params general,
server_params par 
)
static

Definition at line 1281 of file sock.c.

Referenced by do_test().

1283 {
1284  par->general = general;
1285  thread[0] = CreateThread ( NULL, 0, routine, par, 0, &thread_id[0] );
1286  ok ( thread[0] != NULL, "Failed to create server thread\n" );
1287 }
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:225
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:135
smooth NULL
Definition: ftsmooth.c:557
test_params * general
Definition: sock.c:135
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:226
int jpeg_marker_parser_method routine
Definition: jpeglib.h:1089
#define ok(value,...)
Definition: CImage.cpp:33
static int tcp_socketpair ( SOCKET src,
SOCKET dst 
)
static

Definition at line 236 of file sock.c.

Referenced by test_completion_port(), test_ioctlsocket(), test_select(), test_send(), test_WithWSAStartup(), test_WSAEnumNetworkEvents(), test_WSAPoll(), and test_WSARecv().

237 {
239  struct sockaddr_in addr;
240  int len;
241  int ret;
242 
243  *src = INVALID_SOCKET;
244  *dst = INVALID_SOCKET;
245 
247  if (*src == INVALID_SOCKET)
248  goto end;
249 
251  if (server == INVALID_SOCKET)
252  goto end;
253 
254  memset(&addr, 0, sizeof(addr));
255  addr.sin_family = AF_INET;
256  addr.sin_addr.s_addr = inet_addr("127.0.0.1");
257  ret = bind(server, (struct sockaddr*)&addr, sizeof(addr));
258  if (ret != 0)
259  goto end;
260 
261  len = sizeof(addr);
262  ret = getsockname(server, (struct sockaddr*)&addr, &len);
263  if (ret != 0)
264  goto end;
265 
266  ret = listen(server, 1);
267  if (ret != 0)
268  goto end;
269 
270  ret = connect(*src, (struct sockaddr*)&addr, sizeof(addr));
271  if (ret != 0)
272  goto end;
273 
274  len = sizeof(addr);
275  *dst = accept(server, (struct sockaddr*)&addr, &len);
276 
277 end:
278  if (server != INVALID_SOCKET)
279  closesocket(server);
280  if (*src != INVALID_SOCKET && *dst != INVALID_SOCKET)
281  return 0;
282  closesocket(*src);
283  closesocket(*dst);
284  return -1;
285 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define inet_addr(cp)
Definition: inet.h:98
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
GLuint GLuint end
Definition: gl.h:1545
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
#define closesocket
Definition: main.c:50
#define INVALID_SOCKET
Definition: winsock.h:332
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
#define AF_INET
Definition: tcpip.h:117
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCK_STREAM
Definition: tcpip.h:118
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
static void test_accept ( void  )
static

Definition at line 4252 of file sock.c.

Referenced by START_TEST().

4253 {
4254  int ret;
4256  struct sockaddr_in address;
4257  SOCKADDR_STORAGE ss, ss_empty;
4258  int socklen;
4259  select_thread_params thread_params;
4260  HANDLE thread_handle = NULL;
4261  DWORD id;
4262 
4263  memset(&address, 0, sizeof(address));
4264  address.sin_addr.s_addr = inet_addr("127.0.0.1");
4265  address.sin_family = AF_INET;
4266 
4267  socklen = sizeof(address);
4268  server_socket = setup_server_socket(&address, &socklen);
4269  if (server_socket == INVALID_SOCKET)
4270  {
4271  trace("error creating server socket: %d\n", WSAGetLastError());
4272  return;
4273  }
4274 
4275  connector = setup_connector_socket(&address, socklen, FALSE);
4276  if (connector == INVALID_SOCKET) goto done;
4277 
4278  trace("Blocking accept next\n");
4279 
4280  accepted = WSAAccept(server_socket, NULL, NULL, AlwaysDeferConditionFunc, 0);
4281  ok(accepted == INVALID_SOCKET && WSAGetLastError() == WSATRY_AGAIN, "Failed to defer connection, %d\n", WSAGetLastError());
4282 
4283  accepted = accept(server_socket, NULL, 0);
4284  ok(accepted != INVALID_SOCKET, "Failed to accept deferred connection, error %d\n", WSAGetLastError());
4285 
4288  {
4289  trace("error creating event: %d\n", GetLastError());
4290  goto done;
4291  }
4292 
4293  thread_params.s = server_socket;
4294  thread_params.ReadKilled = FALSE;
4295  thread_handle = CreateThread(NULL, 0, AcceptKillThread, &thread_params, 0, &id);
4296  if (thread_handle == NULL)
4297  {
4298  trace("error creating thread: %d\n", GetLastError());
4299  goto done;
4300  }
4301 
4303  Sleep(200);
4304  ret = closesocket(server_socket);
4305  if (ret != 0)
4306  {
4307  trace("closesocket failed: %d\n", WSAGetLastError());
4308  goto done;
4309  }
4310 
4311  WaitForSingleObject(thread_handle, 1000);
4312  ok(thread_params.ReadKilled || broken(!thread_params.ReadKilled) /* Win98/ME, after accept */,
4313  "closesocket did not wakeup accept\n");
4314 
4315  closesocket(accepted);
4316  closesocket(connector);
4317  accepted = connector = INVALID_SOCKET;
4318 
4319  socklen = sizeof(address);
4320  server_socket =