ReactOS  0.4.11-dev-745-g76daaf9
sock.c File Reference
#include <ntstatus.h>
#include <winsock2.h>
#include <windows.h>
#include <winternl.h>
#include <ws2tcpip.h>
#include <wsipx.h>
#include <wsnwlink.h>
#include <mswsock.h>
#include <mstcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
#include "wine/test.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
 
struct  write_watch_thread_args
 
struct  wsa_async_select_info
 
struct  wsa_recv_info
 

Macros

#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 int tcp_socketpair_ovl (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 DWORD CALLBACK write_watch_thread (void *arg)
 
static void test_write_watch (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)
 
static void sync_read (SOCKET src, SOCKET dst)
 
static void iocp_async_read (SOCKET src, SOCKET dst)
 
static void iocp_async_read_closesocket (SOCKET src, int how_to_close)
 
static void iocp_async_closesocket (SOCKET src)
 
static DWORD WINAPI wsa_async_select_thread (void *param)
 
static DWORD WINAPI wsa_recv_thread (void *param)
 
static void iocp_async_read_thread_closesocket (SOCKET src)
 
static void iocp_async_read_thread (SOCKET src, SOCKET dst)
 
static void test_iocp (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 BIND_SLEEP   10 /* seconds to wait between attempts to bind() */

Definition at line 48 of file sock.c.

Referenced by do_bind().

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

Definition at line 49 of file sock.c.

Referenced by do_bind().

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

Definition at line 8829 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 3781 of file sock.c.

Referenced by test_select().

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

Definition at line 3780 of file sock.c.

Referenced by test_select().

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

Definition at line 47 of file sock.c.

Referenced by fill_buffer(), and test_buffer().

Definition at line 2003 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 69 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 56 of file sock.c.

Referenced by do_getservbyname().

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

Definition at line 55 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 53 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 5775 of file sock.c.

Referenced by test_events().

#define POLL_CLEAR ( )    ix = 0

Definition at line 7112 of file sock.c.

Referenced by test_WSAPoll().

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

Definition at line 7114 of file sock.c.

Referenced by test_WSAPoll().

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

Definition at line 7113 of file sock.c.

Referenced by test_WSAPoll().

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

Definition at line 58 of file sock.c.

Referenced by SelectReadThread(), test_ioctlsocket(), 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 1406 of file sock.c.

Referenced by test_set_getsockopt().

#define SOCKTIMEOUT2   997000 /* 997 seconds */

Definition at line 1408 of file sock.c.

Referenced by test_set_getsockopt().

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

Definition at line 2186 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 50 of file sock.c.

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

#define WIN32_NO_STATUS

Definition at line 30 of file sock.c.

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

Definition at line 44 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:223
int int int * err
Definition: fci.h:172
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define ok(value,...)
Definition: CComObject.cpp:34
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:717
UINT msg
Definition: msvc.h:92
static int(WINAPI *pgetaddrinfo)(LPCSTR

Definition at line 61 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 4160 of file sock.c.

Referenced by test_accept().

4161 {
4162  select_thread_params *par = param;
4163  struct sockaddr_in address;
4164  int len = sizeof(address);
4165  SOCKET client_socket;
4166 
4168  client_socket = accept(par->s, (struct sockaddr*) &address, &len);
4169  if (client_socket != INVALID_SOCKET)
4170  closesocket(client_socket);
4171  par->ReadKilled = (client_socket == INVALID_SOCKET);
4172  return 0;
4173 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define closesocket
Definition: main.c:39
#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:233
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 4176 of file sock.c.

Referenced by test_accept(), and test_AcceptEx().

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

Definition at line 437 of file sock.c.

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

438 {
439  int tmp = 1, len;
440  len = sizeof (tmp);
442  ok ( tmp == 0, "check_so_opentype: wrong startup value of SO_OPENTYPE: %d\n", tmp );
443 }
#define SOL_SOCKET
Definition: winsock.h:398
#define ok(value,...)
Definition: CComObject.cpp:34
#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
static void client_start ( client_params par)
static

Definition at line 567 of file sock.c.

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

568 {
569  test_params *gen = par->general;
571 
572  TlsSetValue ( tls, mem );
573 
575 
576  mem->s = WSASocketA ( AF_INET, gen->sock_type, gen->sock_prot,
577  NULL, 0, par->sock_flags );
578 
579  mem->addr.sin_family = AF_INET;
580  mem->addr.sin_addr.s_addr = inet_addr ( gen->inet_addr );
581  mem->addr.sin_port = htons ( gen->inet_port );
582 
583  ok ( mem->s != INVALID_SOCKET, "Client: WSASocket failed\n" );
584 
585  mem->send_buf = LocalAlloc ( LPTR, 2 * gen->n_chunks * gen->chunk_size );
586  mem->recv_buf = mem->send_buf + gen->n_chunks * gen->chunk_size;
587  fill_buffer ( mem->send_buf, gen->chunk_size, gen->n_chunks );
588 
590  /* Wait for the other clients to come up */
592 }
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:149
char * recv_buf
Definition: sock.c:178
#define inet_addr(cp)
Definition: inet.h:98
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1199
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:235
int sock_prot
Definition: sock.c:130
smooth NULL
Definition: ftsmooth.c:416
int sock_type
Definition: sock.c:129
#define ok(value,...)
Definition: CComObject.cpp:34
#define MAX_CLIENTS
Definition: sock.c:46
struct sockaddr_in addr
Definition: sock.c:176
#define INVALID_SOCKET
Definition: winsock.h:332
SOCKET s
Definition: sock.c:175
const char * inet_addr
Definition: sock.c:131
static void fill_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:362
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:234
short inet_port
Definition: sock.c:132
int n_clients
Definition: sock.c:135
DWORD sock_flags
Definition: sock.c:150
#define min(a, b)
Definition: monoChain.cc:55
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
char * send_buf
Definition: sock.c:177
#define AF_INET
Definition: tcpip.h:117
#define LPTR
Definition: winbase.h:362
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
static DWORD tls
Definition: sock.c:230
static HANDLE server_ready
Definition: sock.c:233
#define htons(x)
Definition: module.h:213
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:134
static void client_stop ( void  )
static

Definition at line 594 of file sock.c.

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

595 {
597  wsa_ok ( closesocket ( mem->s ), 0 ==, "closesocket error (%x): %d\n" );
598  LocalFree ( mem->send_buf );
599  LocalFree ( mem );
600  ExitThread(0);
601 }
#define closesocket
Definition: main.c:39
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
SOCKET s
Definition: sock.c:175
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
Definition: mem.c:156
char * send_buf
Definition: sock.c:177
static DWORD tls
Definition: sock.c:230
static void compare_addrinfo ( ADDRINFO a,
ADDRINFO b 
)
static

Definition at line 445 of file sock.c.

Referenced by test_getaddrinfo().

446 {
447  for (; a && b ; a = a->ai_next, b = b->ai_next)
448  {
449  ok(a->ai_flags == b->ai_flags,
450  "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
451  ok(a->ai_family == b->ai_family,
452  "Wrong family %d != %d\n", a->ai_family, b->ai_family);
453  ok(a->ai_socktype == b->ai_socktype,
454  "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
455  ok(a->ai_protocol == b->ai_protocol,
456  "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
457  ok(a->ai_addrlen == b->ai_addrlen,
458  "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
459  ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
460  "Wrong address data\n");
461  if (a->ai_canonname && b->ai_canonname)
462  {
463  ok(!strcmp(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
464  a->ai_canonname, b->ai_canonname);
465  }
466  else
467  ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
468  a->ai_canonname, b->ai_canonname);
469  }
470  ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
471 }
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
#define ok(value,...)
Definition: CComObject.cpp:34
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
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 473 of file sock.c.

Referenced by test_GetAddrInfoW().

474 {
475  for (; a && b ; a = a->ai_next, b = b->ai_next)
476  {
477  ok(a->ai_flags == b->ai_flags,
478  "Wrong flags %d != %d\n", a->ai_flags, b->ai_flags);
479  ok(a->ai_family == b->ai_family,
480  "Wrong family %d != %d\n", a->ai_family, b->ai_family);
481  ok(a->ai_socktype == b->ai_socktype,
482  "Wrong socktype %d != %d\n", a->ai_socktype, b->ai_socktype);
483  ok(a->ai_protocol == b->ai_protocol,
484  "Wrong protocol %d != %d\n", a->ai_protocol, b->ai_protocol);
485  ok(a->ai_addrlen == b->ai_addrlen,
486  "Wrong addrlen %lu != %lu\n", a->ai_addrlen, b->ai_addrlen);
487  ok(!memcmp(a->ai_addr, b->ai_addr, min(a->ai_addrlen, b->ai_addrlen)),
488  "Wrong address data\n");
489  if (a->ai_canonname && b->ai_canonname)
490  {
491  ok(!lstrcmpW(a->ai_canonname, b->ai_canonname), "Wrong canonical name '%s' != '%s'\n",
492  wine_dbgstr_w(a->ai_canonname), wine_dbgstr_w(b->ai_canonname));
493  }
494  else
495  ok(!a->ai_canonname && !b->ai_canonname, "Expected both names absent (%p != %p)\n",
496  a->ai_canonname, b->ai_canonname);
497  }
498  ok(!a && !b, "Expected both addresses null (%p != %p)\n", a, b);
499 }
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
#define ok(value,...)
Definition: CComObject.cpp:34
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
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 8831 of file sock.c.

8832 {
8833  char buf1[256], buf2[256];
8834  BOOL success;
8835  int i = 0;
8836 
8838  while (1)
8839  {
8840  DWORD n1 = 0, n2 = 0;
8841 
8842  success = ReadFile(handle, buf1, sizeof(buf1), &n1, NULL);
8843  ok_(file,line)(success, "Failed to read from file.\n");
8844  if (success && n1 == 0)
8845  break;
8846  else if(!success)
8847  return;
8848  n2 = recv(sock, buf2, n1, 0);
8849  ok_(file,line)(n1 == n2, "Block %d size mismatch (%d != %d)\n", i, n1, n2);
8850  ok_(file,line)(memcmp(buf1, buf2, n2) == 0, "Block %d failed\n", i);
8851  i++;
8852  }
8853 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLintptr offset
Definition: glext.h:5920
DWORD DWORD
Definition: winlogon.h:84
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:416
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:112
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
Definition: fci.c:126
static HWND create_async_message_window ( void  )
static

Definition at line 9496 of file sock.c.

Referenced by test_WSAAsyncGetServByName(), and test_WSAAsyncGetServByPort().

9497 {
9498  static const char class_name[] = "ws2_32 async message window class";
9499 
9500  WNDCLASSEXA wndclass;
9501  HWND hWnd;
9502 
9503  wndclass.cbSize = sizeof(wndclass);
9504  wndclass.style = CS_HREDRAW | CS_VREDRAW;
9505  wndclass.lpfnWndProc = DefWindowProcA;
9506  wndclass.cbClsExtra = 0;
9507  wndclass.cbWndExtra = 0;
9508  wndclass.hInstance = GetModuleHandleA(NULL);
9509  wndclass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
9511  wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
9512  wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
9513  wndclass.lpszClassName = class_name;
9514  wndclass.lpszMenuName = NULL;
9515 
9516  RegisterClassExA(&wndclass);
9517 
9518  hWnd = CreateWindowA(class_name, "ws2_32 async message window", WS_OVERLAPPEDWINDOW,
9519  0, 0, 500, 500, NULL, NULL, GetModuleHandleA(NULL), NULL);
9520  if (!hWnd)
9521  {
9522  ok(0, "failed to create window: %u\n", GetLastError());
9523  return NULL;
9524  }
9525 
9526  return hWnd;
9527 }
UINT style
Definition: winuser.h:3155
LPCSTR lpszMenuName
Definition: winuser.h:3163
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_APPLICATION
Definition: winuser.h:699
HICON hIconSm
Definition: winuser.h:3165
#define COLOR_WINDOW
Definition: winuser.h:908
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
HINSTANCE hInstance
Definition: winuser.h:3159
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
const char * LPCSTR
Definition: xmlstorage.h:183
HBRUSH hbrBackground
Definition: winuser.h:3162
#define ok(value,...)
Definition: CComObject.cpp:34
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3158
HICON hIcon
Definition: winuser.h:3160
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
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:2059
int cbClsExtra
Definition: winuser.h:3157
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static const char* dbgstr_event_seq ( const LPARAM seq)
static

Definition at line 5566 of file sock.c.

Referenced by ok_event_sequence().

5567 {
5568  static char message[1024];
5569  char name[12];
5570  int len = 1;
5571 
5572  message[0] = '[';
5573  message[1] = 0;
5574  while (*seq)
5575  {
5577  len += sprintf(message + len, "%s(%d) ", name, WSAGETSELECTERROR(*seq));
5578  seq++;
5579  }
5580  if (len > 1) len--;
5581  strcpy( message + len, "]" );
5582  return message;
5583 }
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:416
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
GLenum GLsizei len
Definition: glext.h:6722
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
Definition: name.c:36
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:5532
static char* dbgstr_event_seq_result ( SOCKET  s,
WSANETWORKEVENTS netEvents 
)
static

Definition at line 5585 of file sock.c.

Referenced by ok_event_sequence().

5586 {
5587  static char message[1024];
5588  struct async_message *curr = messages_received;
5589  int index, error, bit = 0;
5590  char name[12];
5591  int len = 1;
5592 
5593  message[0] = '[';
5594  message[1] = 0;
5595  while (1)
5596  {
5597  if (netEvents)
5598  {
5599  if (bit >= FD_MAX_EVENTS) break;
5600  if ( !(netEvents->lNetworkEvents & (1 << bit)) )
5601  {
5602  bit++;
5603  continue;
5604  }
5605  get_event_details(1 << bit, &index, name);
5606  error = netEvents->iErrorCode[index];
5607  bit++;
5608  }
5609  else
5610  {
5611  if (!curr) break;
5612  if (curr->socket != s)
5613  {
5614  curr = curr->next;
5615  continue;
5616  }
5618  error = WSAGETSELECTERROR(curr->lparam);
5619  curr = curr->next;
5620  }
5621 
5622  len += sprintf(message + len, "%s(%d) ", name, error);
5623  }
5624  if (len > 1) len--;
5625  strcpy( message + len, "]" );
5626  return message;
5627 }
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:5500
SOCKET socket
Definition: sock.c:5498
static struct async_message * messages_received
Definition: sock.c:5503
#define sprintf(buf, format,...)
Definition: sprintf.c:55
LPARAM lparam
Definition: sock.c:5499
smooth NULL
Definition: ftsmooth.c:416
#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:36
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:5532
static void do_bind ( SOCKET  s,
struct sockaddr addr,
int  addrlen 
)
static

Definition at line 508 of file sock.c.

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

509 {
510  int err, wsaerr = 0, n_try = BIND_TRIES;
511 
512  while ( ( err = bind ( s, addr, addrlen ) ) != 0 &&
513  ( wsaerr = WSAGetLastError () ) == WSAEADDRINUSE &&
514  n_try-- >= 0)
515  {
516  trace ( "address in use, waiting ...\n" );
517  Sleep ( 1000 * BIND_SLEEP );
518  }
519  ok ( err == 0, "failed to bind: %d\n", wsaerr );
520 }
#define trace(...)
Definition: kmt_test.h:217
#define BIND_SLEEP
Definition: sock.c:48
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:49
#define ok(value,...)
Definition: CComObject.cpp:34
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLdouble s
Definition: gl.h:2039
#define err(...)
#define WSAEADDRINUSE
Definition: winerror.h:1961
static DWORD WINAPI do_getservbyname ( void param)
static

Definition at line 2349 of file sock.c.

Referenced by test_getservbyname().

2350 {
2351  struct {
2352  const char *name;
2353  const char *proto;
2354  int port;
2355  } serv[2] = { {"domain", "udp", 53}, {"telnet", "tcp", 23} };
2356 
2357  HANDLE *starttest = param;
2358  int i, j;
2359  struct servent *pserv[2];
2360 
2361  ok ( WaitForSingleObject ( *starttest, TEST_TIMEOUT * 1000 ) != WAIT_TIMEOUT,
2362  "test_getservbyname: timeout waiting for start signal\n" );
2363 
2364  /* ensure that necessary buffer resizes are completed */
2365  for ( j = 0; j < 2; j++) {
2366  pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
2367  }
2368 
2369  for ( i = 0; i < NUM_QUERIES / 2; i++ ) {
2370  for ( j = 0; j < 2; j++ ) {
2371  pserv[j] = getservbyname ( serv[j].name, serv[j].proto );
2372  ok ( pserv[j] != NULL || broken(pserv[j] == NULL) /* win8, fixed in win81 */,
2373  "getservbyname could not retrieve information for %s: %d\n", serv[j].name, WSAGetLastError() );
2374  if ( !pserv[j] ) continue;
2375  ok ( pserv[j]->s_port == htons(serv[j].port),
2376  "getservbyname returned the wrong port for %s: %d\n", serv[j].name, ntohs(pserv[j]->s_port) );
2377  ok ( !strcmp ( pserv[j]->s_proto, serv[j].proto ),
2378  "getservbyname returned the wrong protocol for %s: %s\n", serv[j].name, pserv[j]->s_proto );
2379  ok ( !strcmp ( pserv[j]->s_name, serv[j].name ),
2380  "getservbyname returned the wrong name for %s: %s\n", serv[j].name, pserv[j]->s_name );
2381  }
2382 
2383  ok ( pserv[0] == pserv[1] || broken(pserv[0] != pserv[1]) /* win8, fixed in win81 */,
2384  "getservbyname: winsock resized servent buffer when not necessary\n" );
2385  }
2386 
2387  return 0;
2388 }
#define NUM_QUERIES
Definition: sock.c:56
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:50
#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:416
#define ok(value,...)
Definition: CComObject.cpp:34
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:61
short s_port
Definition: winsock.h:165
Definition: name.c:36
char * s_proto
Definition: winsock.h:166
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define htons(x)
Definition: module.h:213
USHORT port
Definition: uri.c:227
static int do_synchronous_recv ( SOCKET  s,
char buf,
int  buflen,
int  flags,
int  recvlen 
)
static

Definition at line 407 of file sock.c.

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

408 {
409  char* last = buf + buflen, *p;
410  int n = 1;
411  for ( p = buf; n > 0 && p < last; )
412  {
413  n = recv ( s, p, min ( recvlen, last - p ), flags );
414  if (n > 0) p += n;
415  }
416  wsa_ok ( n, 0 <=, "do_synchronous_recv (%x): error %d:\n" );
417  return p - buf;
418 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
POINT last
Definition: font.c:46
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:61
#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 420 of file sock.c.

Referenced by simple_mixed_client().

421 {
422  char* last = buf + buflen, *p;
423  int n = 1;
424  for ( p = buf; n > 0 && p < last; )
425  {
426  n = recvfrom ( s, p, min ( recvlen, last - p ), flags, from, fromlen );
427  if (n > 0) p += n;
428  }
429  wsa_ok ( n, 0 <=, "do_synchronous_recv (%x): error %d:\n" );
430  return p - buf;
431 }
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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
POINT last
Definition: font.c:46
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:61
#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 394 of file sock.c.

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

395 {
396  char* last = buf + buflen, *p;
397  int n = 1;
398  for ( p = buf; n > 0 && p < last; )
399  {
400  n = send ( s, p, min ( sendlen, last - p ), flags );
401  if (n > 0) p += n;
402  }
403  wsa_ok ( n, 0 <=, "do_synchronous_send (%x): error %d\n" );
404  return p - buf;
405 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
POINT last
Definition: font.c:46
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:61
#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 1363 of file sock.c.

Referenced by START_TEST().

1364 {
1365  DWORD i, n = min (test->general.n_clients, MAX_CLIENTS);
1366  DWORD wait;
1367 
1369  for (i = 0; i <= n; i++)
1371 
1372  StartServer ( test->srv, &test->general, &test->srv_params );
1373  StartClients ( test->clt, &test->general, &test->clt_params );
1375 
1376  wait = WaitForMultipleObjects ( 1 + n, thread, TRUE, 1000 * TEST_TIMEOUT );
1377  ok ( wait <= WAIT_OBJECT_0 + n ,
1378  "some threads have not completed: %x\n", wait );
1379 
1380  if ( ! ( wait <= WAIT_OBJECT_0 + n ) )
1381  {
1382  for (i = 0; i <= n; i++)
1383  {
1384  if ( WaitForSingleObject ( thread[i], 0 ) != WAIT_OBJECT_0 )
1385  {
1386  trace ("terminating thread %08x\n", thread_id[i]);
1387  TerminateThread ( thread [i], 0 );
1388  }
1389  }
1390  }
1392  for (i = 0; i <= n; i++)
1393  CloseHandle ( client_ready[i] );
1394 }
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define TEST_TIMEOUT
Definition: sock.c:50
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:549
static void StartClients(LPTHREAD_START_ROUTINE routine, test_params *general, client_params *par)
Definition: sock.c:1348
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:84
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:231
test_params general
Definition: sock.c:157
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:416
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 ok(value,...)
Definition: CComObject.cpp:34
#define MAX_CLIENTS
Definition: sock.c:46
#define WAIT_OBJECT_0
Definition: winbase.h:387
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:232
server_params srv_params
Definition: sock.c:159
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:234
LPVOID srv
Definition: sock.c:158
client_params clt_params
Definition: sock.c:161
LPVOID clt
Definition: sock.c:160
int n_clients
Definition: sock.c:135
#define min(a, b)
Definition: monoChain.cc:55
static void StartServer(LPTHREAD_START_ROUTINE routine, test_params *general, server_params *par)
Definition: sock.c:1340
static HANDLE server_ready
Definition: sock.c:233
#define INFINITE
Definition: serial.h:102
static DWORD WINAPI drain_socket_thread ( LPVOID  arg)
static

Definition at line 5329 of file sock.c.

Referenced by test_events(), and test_send().

5330 {
5331  char buffer[1024];
5332  SOCKET sock = *(SOCKET*)arg;
5333  int ret;
5334 
5335  while ((ret = recv(sock, buffer, sizeof(buffer), 0)) != 0)
5336  {
5337  if (ret < 0)
5338  {
5340  {
5341  fd_set readset;
5342  FD_ZERO(&readset);
5343  FD_SET(sock, &readset);
5344  select(sock+1, &readset, NULL, NULL, NULL);
5345  while (drain_pause)
5346  Sleep(100);
5347  }
5348  else
5349  break;
5350  }
5351  }
5352  return 0;
5353 }
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:416
static BOOL drain_pause
Definition: sock.c:5328
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 1044 of file sock.c.

1045 {
1046  test_params *gen = par->general;
1047  client_memory *mem;
1048  int id = GetCurrentThreadId(), n_expected = gen->n_chunks * gen->chunk_size,
1049  tmp, err, n;
1050  HANDLE event;
1051  WSANETWORKEVENTS wsa_events;
1052  char *send_last, *recv_last, *send_p, *recv_p;
1054 
1055  trace ( "event_client (%x): starting\n", id );
1056  client_start ( par );
1057  trace ( "event_client (%x): server ready\n", id );
1058 
1059  mem = TlsGetValue ( tls );
1060 
1061  /* Prepare event notification for connect, makes socket nonblocking */
1062  event = WSACreateEvent ();
1063  WSAEventSelect ( mem->s, event, FD_CONNECT );
1064  tmp = connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) );
1065  if ( tmp != 0 ) {
1066  err = WSAGetLastError ();
1067  ok ( err == WSAEWOULDBLOCK, "event_client (%x): connect error: %d\n", id, err );
1068  tmp = WaitForSingleObject ( event, INFINITE );
1069  ok ( tmp == WAIT_OBJECT_0, "event_client (%x): wait for connect event failed: %d\n", id, tmp );
1070  err = WSAEnumNetworkEvents ( mem->s, event, &wsa_events );
1071  ok ( err == 0, "event_client (%x): WSAEnumNetworkEvents error: %d\n", id, err );
1072  err = wsa_events.iErrorCode[ FD_CONNECT_BIT ];
1073  ok ( err == 0, "event_client (%x): connect error: %d\n", id, err );
1074  if ( err ) goto out;
1075  }
1076 
1077  trace ( "event_client (%x) connected\n", id );
1078 
1079  WSAEventSelect ( mem->s, event, mask );
1080 
1081  recv_p = mem->recv_buf;
1082  recv_last = mem->recv_buf + n_expected;
1083  send_p = mem->send_buf;
1084  send_last = mem->send_buf + n_expected;
1085 
1086  while ( TRUE )
1087  {
1088  err = WaitForSingleObject ( event, INFINITE );
1089  ok ( err == WAIT_OBJECT_0, "event_client (%x): wait failed\n", id );
1090 
1091  err = WSAEnumNetworkEvents ( mem->s, event, &wsa_events );
1092  ok( err == 0, "event_client (%x): WSAEnumNetworkEvents error: %d\n", id, err );
1093 
1094  if ( wsa_events.lNetworkEvents & FD_WRITE )
1095  {
1096  err = wsa_events.iErrorCode[ FD_WRITE_BIT ];
1097  ok ( err == 0, "event_client (%x): FD_WRITE error code: %d\n", id, err );
1098 
1099  if ( err== 0 )
1100  do
1101  {
1102  n = send ( mem->s, send_p, min ( send_last - send_p, par->buflen ), 0 );
1103  if ( n < 0 )
1104  {
1105  err = WSAGetLastError ();
1106  ok ( err == WSAEWOULDBLOCK, "event_client (%x): send error: %d\n", id, err );
1107  }
1108  else
1109  send_p += n;
1110  }
1111  while ( n >= 0 && send_p < send_last );
1112 
1113  if ( send_p == send_last )
1114  {
1115  trace ( "event_client (%x): all data sent - shutdown\n", id );
1116  shutdown ( mem->s, SD_SEND );
1117  mask &= ~FD_WRITE;
1118  WSAEventSelect ( mem->s, event, mask );
1119  }
1120  }
1121  if ( wsa_events.lNetworkEvents & FD_READ )
1122  {
1123  err = wsa_events.iErrorCode[ FD_READ_BIT ];
1124  ok ( err == 0, "event_client (%x): FD_READ error code: %d\n", id, err );
1125  if ( err != 0 ) break;
1126 
1127  /* First read must succeed */
1128  n = recv ( mem->s, recv_p, min ( recv_last - recv_p, par->buflen ), 0 );
1129  wsa_ok ( n, 0 <=, "event_client (%x): recv error: %d\n" );
1130 
1131  while ( n >= 0 ) {
1132  recv_p += n;
1133  if ( recv_p == recv_last )
1134  {
1135  mask &= ~FD_READ;
1136  trace ( "event_client (%x): all data received\n", id );
1137  WSAEventSelect ( mem->s, event, mask );
1138  break;
1139  }
1140  n = recv ( mem->s, recv_p, min ( recv_last - recv_p, par->buflen ), 0 );
1141  if ( n < 0 && ( err = WSAGetLastError()) != WSAEWOULDBLOCK )
1142  ok ( 0, "event_client (%x): read error: %d\n", id, err );
1143 
1144  }
1145  }
1146  if ( wsa_events.lNetworkEvents & FD_CLOSE )
1147  {
1148  trace ( "event_client (%x): close event\n", id );
1149  err = wsa_events.iErrorCode[ FD_CLOSE_BIT ];
1150  ok ( err == 0, "event_client (%x): FD_CLOSE error code: %d\n", id, err );
1151  break;
1152  }
1153  }
1154 
1155  n = send_p - mem->send_buf;
1156  ok ( send_p == send_last,
1157  "simple_client (%x): sent less data than expected: %d of %d\n", id, n, n_expected );
1158  n = recv_p - mem->recv_buf;
1159  ok ( recv_p == recv_last,
1160  "simple_client (%x): received less data than expected: %d of %d\n", id, n, n_expected );
1161  n = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
1162  ok ( n == -1, "event_client (%x): test pattern error: %d\n", id, n);
1163 
1164 out:
1165  WSACloseEvent ( event );
1166  trace ( "event_client (%x) exiting\n", id );
1167  client_stop ();
1168 }
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:149
char * recv_buf
Definition: sock.c:178
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:421
#define ok(value,...)
Definition: CComObject.cpp:34
#define FD_CLOSE_BIT
Definition: winsock2.h:303
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define FD_CLOSE
Definition: winsock.h:410
struct sockaddr_in addr
Definition: sock.c:176
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:175
static FILE * out
Definition: regtests2xml.c:44
int buflen
Definition: sock.c:151
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:567
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:369
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
DWORD *typedef HANDLE
Definition: winlogon.h:61
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:1163
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
char * send_buf
Definition: sock.c:177
static DWORD tls
Definition: sock.c:230
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:134
static void client_stop(void)
Definition: sock.c:594
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 1331 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(), 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(), CommonInstall(), CreateDIBitmap(), DefSetText(), DispTdiQueryIpHwAddress(), DoAppSwitch(), EngCreateWnd(), EnumHKCRKey(), EnumHKCRValue(), ExtractFont(), fnt_face_get_dll_font(), FNT_Face_Init(), fnt_font_load(), FNT_Load_Glyph(), FsRtlIsDbcsInExpression(), FsRtlIsNameInExpressionPrivate(), 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(), NtGdiExtEscape(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphOutline(), NtGdiSelectClipPath(), NtGdiSetDIBitsToDeviceInternal(), NtGdiSetPixelFormat(), NtGdiSwapBuffers(), NtSetSystemPowerState(), NtStopProfile(), NtUserAttachThreadInput(), NtUserBuildPropList(), NtUserCallHwndLock(), NtUserCallHwndParamLock(), NtUserDeferWindowPos(), NtUserDefSetText(), NtUserDrawCaptionTemp(), NtUserFillWindow(), NtUserFlashWindowEx(), NtUserGetInternalWindowPos(), NtUserGetLayeredWindowAttributes(), NtUserGetObjectInformation(), NtUserMinMaximize(), NtUserPrintWindow(), NtUserRemoveProp(), NtUserSetCursorIconData(), NtUserSetLayeredWindowAttributes(), NtUserSetProp(), NtUserSetSystemCursor(), NtUserTrackPopupMenuEx(), NtUserUpdateLayeredWindow(), NtUserVkKeyScanEx(), OHCI_AbortTransfer(), 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(), ProgressCountdown(), 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(), T42_Face_Init(), t42_load_keyword(), T42_Open_Face(), t42_parse_dict(), t42_parse_sfnts(), t42_parser_init(), TreeListKeyDown(), 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().

1332 {
1333  INT ret, err;
1334  TlsFree ( tls );
1335  ret = WSACleanup();
1336  err = WSAGetLastError();
1337  ok ( ret == 0, "WSACleanup failed ret = %d GetLastError is %d\n", ret, err);
1338 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
int32_t INT
Definition: typedefs.h:56
#define ok(value,...)
Definition: CComObject.cpp:34
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1089
int ret
#define err(...)
static DWORD tls
Definition: sock.c:230
static void fill_buffer ( char buf,
int  chunk_size,
int  n_chunks 
)
static

Definition at line 362 of file sock.c.

Referenced by client_start().

363 {
364  char c, *p;
365  for ( c = FIRST_CHAR, p = buf; c < FIRST_CHAR + n_chunks; c++, p += chunk_size )
366  memset ( p, c, chunk_size );
367 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FIRST_CHAR
Definition: sock.c:47
#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 5629 of file sock.c.

Referenced by ok_event_sequence(), and test_events().

5630 {
5631  WSANETWORKEVENTS netEvents;
5632  struct async_message *prev = NULL, *curr = messages_received;
5633  int ret;
5634  DWORD dwRet;
5635 
5637  {
5638  dwRet = WaitForSingleObject(hEvent, 100);
5639  if (dwRet == WAIT_OBJECT_0)
5640  {
5641  ret = WSAEnumNetworkEvents(s, hEvent, &netEvents);
5642  if (ret)
5643  ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5644  }
5645  }
5646  else
5647  {
5648  while (curr)
5649  {
5650  if (curr->socket == s)
5651  {
5652  if (prev) prev->next = curr->next;
5653  else messages_received = curr->next;
5654 
5655  HeapFree(GetProcessHeap(), 0, curr);
5656 
5657  if (prev) curr = prev->next;
5658  else curr = messages_received;
5659  }
5660  else
5661  {
5662  prev = curr;
5663  curr = curr->next;
5664  }
5665  }
5666  }
5667 }
struct async_message * next
Definition: sock.c:5500
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD DWORD
Definition: winlogon.h:84
static struct async_message * messages_received
Definition: sock.c:5503
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:416
#define ok(value,...)
Definition: CComObject.cpp:34
#define WAIT_OBJECT_0
Definition: winbase.h:387
#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 HeapFree(x, y, z)
Definition: compat.h:394
static void get_event_details ( int  event,
int bit,
char name 
)
static

Definition at line 5532 of file sock.c.

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

5533 {
5534  switch (event)
5535  {
5536  case FD_ACCEPT:
5537  if (bit) *bit = FD_ACCEPT_BIT;
5538  if (name) strcpy(name, "FD_ACCEPT");
5539  break;
5540  case FD_CONNECT:
5541  if (bit) *bit = FD_CONNECT_BIT;
5542  if (name) strcpy(name, "FD_CONNECT");
5543  break;
5544  case FD_READ:
5545  if (bit) *bit = FD_READ_BIT;
5546  if (name) strcpy(name, "FD_READ");
5547  break;
5548  case FD_OOB:
5549  if (bit) *bit = FD_OOB_BIT;
5550  if (name) strcpy(name, "FD_OOB");
5551  break;
5552  case FD_WRITE:
5553  if (bit) *bit = FD_WRITE_BIT;
5554  if (name) strcpy(name, "FD_WRITE");
5555  break;
5556  case FD_CLOSE:
5557  if (bit) *bit = FD_CLOSE_BIT;
5558  if (name) strcpy(name, "FD_CLOSE");
5559  break;
5560  default:
5561  if (bit) *bit = -1;
5562  if (name) sprintf(name, "bad%x", event);
5563  }
5564 }
#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:36
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 10542 of file sock.c.

Referenced by test_inet_ntoa().

10543 {
10544  ULONG addr;
10545  const char *str;
10546  HANDLE *event = param;
10547 
10548  addr = inet_addr("4.3.2.1");
10549  ok(addr == htonl(0x04030201), "expected 0x04030201, got %08x\n", addr);
10550  str = inet_ntoa(*(struct in_addr *)&addr);
10551  ok(!strcmp(str, "4.3.2.1"), "expected 4.3.2.1, got %s\n", str);
10552 
10553  SetEvent(event[0]);
10554  WaitForSingleObject(event[1], 3000);
10555 
10556  return 0;
10557 }
#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
#define ok(value,...)
Definition: CComObject.cpp:34
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:61
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void Init ( void  )
static

Definition at line 1288 of file sock.c.

Referenced by START_TEST().

1289 {
1290  WORD ver = MAKEWORD (2, 2);
1291  WSADATA data;
1292  HMODULE hws2_32 = GetModuleHandleA("ws2_32.dll"), hiphlpapi, ntdll;
1293 
1294  pfreeaddrinfo = (void *)GetProcAddress(hws2_32, "freeaddrinfo");
1295  pgetaddrinfo = (void *)GetProcAddress(hws2_32, "getaddrinfo");
1296  pFreeAddrInfoW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoW");
1297  pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
1298  pGetAddrInfoW = (void *)GetProcAddress(hws2_32, "GetAddrInfoW");
1299  pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
1300  pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult");
1301  pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
1302  pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
1303  pInetPtonA = (void *)GetProcAddress(hws2_32, "inet_pton");
1304  pInetPtonW = (void *)GetProcAddress(hws2_32, "InetPtonW");
1305  pWSALookupServiceBeginW = (void *)GetProcAddress(hws2_32, "WSALookupServiceBeginW");
1306  pWSALookupServiceEnd = (void *)GetProcAddress(hws2_32, "WSALookupServiceEnd");
1307  pWSALookupServiceNextW = (void *)GetProcAddress(hws2_32, "WSALookupServiceNextW");
1308  pWSAEnumNameSpaceProvidersA = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersA");
1309  pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW");
1310  pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll");
1311 
1312  hiphlpapi = LoadLibraryA("iphlpapi.dll");
1313  if (hiphlpapi)
1314  {
1315  pGetIpForwardTable = (void *)GetProcAddress(hiphlpapi, "GetIpForwardTable");
1316  pGetAdaptersInfo = (void *)GetProcAddress(hiphlpapi, "GetAdaptersInfo");
1317  }
1318 
1319  ntdll = LoadLibraryA("ntdll.dll");
1320  if (ntdll)
1321  {
1322  pNtClose = (void *)GetProcAddress(ntdll, "NtClose");
1323  pNtSetInformationFile = (void *)GetProcAddress(ntdll, "NtSetInformationFile");
1324  pNtQueryInformationFile = (void *)GetProcAddress(ntdll, "NtQueryInformationFile");
1325  }
1326 
1327  ok ( WSAStartup ( ver, &data ) == 0, "WSAStartup failed\n" );
1328  tls = TlsAlloc();
1329 }
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
#define ok(value,...)
Definition: CComObject.cpp:34
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1023
HANDLE HMODULE
Definition: typedefs.h:75
#define GetProcAddress(x, y)
Definition: compat.h:410
static DWORD tls
Definition: sock.c:230
static void WINAPI io_completion ( DWORD  error,
DWORD  transferred,
WSAOVERLAPPED overlapped,
DWORD  flags 
)
static

Definition at line 6741 of file sock.c.

Referenced by test_WSARecv().

6742 {
6744 }
static int completion_called
Definition: sock.c:6739
static void iocp_async_closesocket ( SOCKET  src)
static

Definition at line 11143 of file sock.c.

Referenced by test_iocp().

11144 {
11145  HANDLE port;
11146  WSAOVERLAPPED *ovl_iocp;
11147  int ret;
11148  DWORD bytes;
11149  ULONG_PTR key;
11150  HWND hwnd;
11151  MSG msg;
11152 
11153  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11154  0, 0, 0, 0, NULL, NULL, 0, NULL);
11155  ok(hwnd != 0, "CreateWindowEx failed\n");
11156 
11158  ok(!ret, "got %d\n", ret);
11159 
11160  Sleep(100);
11161  memset(&msg, 0, sizeof(msg));
11162  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11163  ok(ret, "got %d\n", ret);
11164  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11165  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11166  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11167  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11168 
11169  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11170  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11171 
11172  Sleep(100);
11173  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11174  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11175 
11176  bytes = 0xdeadbeef;
11177  key = 0xdeadbeef;
11178  ovl_iocp = (void *)0xdeadbeef;
11179  SetLastError(0xdeadbeef);
11180  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11181  ok(!ret, "got %d\n", ret);
11182  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11183  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11184  ok(key == 0xdeadbeef, "got key %lu\n", key);
11185  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11186 
11187  Sleep(100);
11188  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11189  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11190 
11191  closesocket(src);
11192 
11193  Sleep(100);
11194  memset(&msg, 0, sizeof(msg));
11195  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11196  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11197 
11198  bytes = 0xdeadbeef;
11199  key = 0xdeadbeef;
11200  ovl_iocp = (void *)0xdeadbeef;
11201  SetLastError(0xdeadbeef);
11202  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11203  ok(!ret, "got %d\n", ret);
11204  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11205  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11206  ok(key == 0xdeadbeef, "got key %lu\n", key);
11207  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11208 
11209  CloseHandle(port);
11210 
11211  DestroyWindow(hwnd);
11212 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define FD_ACCEPT
Definition: winsock.h:408
#define FD_CONNECT
Definition: winsock.h:409
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FD_READ
Definition: winsock.h:405
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define FD_OOB
Definition: winsock.h:407
DWORD DWORD
Definition: winlogon.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FD_WRITE
Definition: winsock.h:406
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define closesocket
Definition: main.c:39
smooth NULL
Definition: ftsmooth.c:416
INT WSAAPI WSAAsyncSelect(IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent)
Definition: select.c:134
#define WM_SOCKET
Definition: sock.c:5505
#define ok(value,...)
Definition: CComObject.cpp:34
#define FD_CLOSE
Definition: winsock.h:410
#define SetLastError(x)
Definition: compat.h:409
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
HKEY key
Definition: reg.c:42
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
#define WS_POPUP
Definition: pedump.c:616
#define WSAOVERLAPPED
Definition: winsock2.h:587
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define PM_REMOVE
Definition: winuser.h:1182
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
static void iocp_async_read ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 10932 of file sock.c.

Referenced by test_iocp().

10933 {
10934  HANDLE port;
10935  WSAOVERLAPPED ovl, *ovl_iocp;
10936  WSABUF buf;
10937  int ret;
10938  char data[512];
10939  DWORD flags, bytes;
10940  ULONG_PTR key;
10941 
10942  memset(data, 0, sizeof(data));
10943  memset(&ovl, 0, sizeof(ovl));
10944 
10945  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
10946  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
10947 
10948  buf.len = sizeof(data);
10949  buf.buf = data;
10950  bytes = 0xdeadbeef;
10951  flags = 0;
10952  SetLastError(0xdeadbeef);
10953  ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL);
10954  ok(ret == SOCKET_ERROR, "got %d\n", ret);
10955  ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
10956  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
10957 
10958  bytes = 0xdeadbeef;
10959  key = 0xdeadbeef;
10960  ovl_iocp = (void *)0xdeadbeef;
10961  SetLastError(0xdeadbeef);
10962  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
10963  ok(!ret, "got %d\n", ret);
10964  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
10965  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
10966  ok(key == 0xdeadbeef, "got key %#lx\n", key);
10967  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
10968 
10969  ret = send(dst, "Hello World!", 12, 0);
10970  ok(ret == 12, "send returned %d\n", ret);
10971 
10972  bytes = 0xdeadbeef;
10973  key = 0xdeadbeef;
10974  ovl_iocp = NULL;
10975  SetLastError(0xdeadbeef);
10976  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
10977  ok(ret, "got %d\n", ret);
10978  ok(bytes == 12, "got bytes %u\n", bytes);
10979  ok(key == 0x12345678, "got key %#lx\n", key);
10980  ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp);
10981  if (ovl_iocp)
10982  {
10983  ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh);
10984  ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal);
10985  ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data);
10986  }
10987 
10988  bytes = 0xdeadbeef;
10989  key = 0xdeadbeef;
10990  ovl_iocp = (void *)0xdeadbeef;
10991  SetLastError(0xdeadbeef);
10992  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
10993  ok(!ret, "got %d\n", ret);
10994  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
10995  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
10996  ok(key == 0xdeadbeef, "got key %#lx\n", key);
10997  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
10998 
10999  CloseHandle(port);
11000 }
#define SOCKET_ERROR
Definition: winsock.h:333
#define CloseHandle
Definition: compat.h:398
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_IO_PENDING
Definition: dderror.h:15
DWORD DWORD
Definition: winlogon.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
smooth NULL
Definition: ftsmooth.c:416
#define ok(value,...)
Definition: CComObject.cpp:34
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
ULONG len
Definition: ws2def.h:519
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
HKEY key
Definition: reg.c:42
CHAR FAR * buf
Definition: ws2def.h:520
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
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
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
#define WSAOVERLAPPED
Definition: winsock2.h:587
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
static void iocp_async_read_closesocket ( SOCKET  src,
int  how_to_close 
)
static

Definition at line 11002 of file sock.c.

Referenced by test_iocp().

11003 {
11004  HANDLE port;
11005  WSAOVERLAPPED ovl, *ovl_iocp;
11006  WSABUF buf;
11007  int ret;
11008  char data[512];
11009  DWORD flags, bytes;
11010  ULONG_PTR key;
11011  HWND hwnd;
11012  MSG msg;
11013 
11014  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11015  0, 0, 0, 0, NULL, NULL, 0, NULL);
11016  ok(hwnd != 0, "CreateWindowEx failed\n");
11017 
11019  ok(!ret, "got %d\n", ret);
11020 
11021  Sleep(100);
11022  memset(&msg, 0, sizeof(msg));
11023  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11024  ok(ret, "got %d\n", ret);
11025  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11026  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11027  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11028  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11029 
11030  memset(data, 0, sizeof(data));
11031  memset(&ovl, 0, sizeof(ovl));
11032 
11033  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11034  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11035 
11036  Sleep(100);
11037  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11038  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11039 
11040  buf.len = sizeof(data);
11041  buf.buf = data;
11042  bytes = 0xdeadbeef;
11043  flags = 0;
11044  SetLastError(0xdeadbeef);
11045  ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL);
11046  ok(ret == SOCKET_ERROR, "got %d\n", ret);
11047  ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
11048  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11049 
11050  Sleep(100);
11051  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11052  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11053 
11054  bytes = 0xdeadbeef;
11055  key = 0xdeadbeef;
11056  ovl_iocp = (void *)0xdeadbeef;
11057  SetLastError(0xdeadbeef);
11058  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11059  ok(!ret, "got %d\n", ret);
11060  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11061  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11062  ok(key == 0xdeadbeef, "got key %#lx\n", key);
11063  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11064 
11065  Sleep(100);
11066  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11067  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11068 
11069  switch (how_to_close)
11070  {
11071  case 0:
11072  closesocket(src);
11073  break;
11074  case 1:
11076  break;
11077  case 2:
11078  pNtClose((HANDLE)src);
11079  break;
11080  default:
11081  ok(0, "wrong value %d\n", how_to_close);
11082  break;
11083  }
11084 
11085  Sleep(200);
11086  memset(&msg, 0, sizeof(msg));
11087  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11088  switch (how_to_close)
11089  {
11090  case 0:
11091  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11092  break;
11093  case 1:
11094  case 2:
11095 todo_wine
11096 {
11097  ok(ret, "got %d\n", ret);
11098  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11099  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11100  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11101  ok(msg.lParam == 0x20, "got %08lx\n", msg.lParam);
11102 }
11103  break;
11104  default:
11105  ok(0, "wrong value %d\n", how_to_close);
11106  break;
11107  }
11108 
11109  bytes = 0xdeadbeef;
11110  key = 0xdeadbeef;
11111  ovl_iocp = NULL;
11112  SetLastError(0xdeadbeef);
11113  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11114  ok(!ret, "got %d\n", ret);
11115 todo_wine
11117  ok(!bytes, "got bytes %u\n", bytes);
11118  ok(key == 0x12345678, "got key %#lx\n", key);
11119  ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp);
11120  if (ovl_iocp)
11121  {
11122  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11123 todo_wine
11124  ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11125  }
11126 
11127  bytes = 0xdeadbeef;
11128  key = 0xdeadbeef;
11129  ovl_iocp = (void *)0xdeadbeef;
11130  SetLastError(0xdeadbeef);
11131  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11132  ok(!ret, "got %d\n", ret);
11133  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11134  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11135  ok(key == 0xdeadbeef, "got key %#lx\n", key);
11136  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11137 
11138  CloseHandle(port);
11139 
11140  DestroyWindow(hwnd);
11141 }
#define ERROR_NETNAME_DELETED
Definition: winerror.h:156
#define SOCKET_ERROR
Definition: winsock.h:333
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define ERROR_CONNECTION_ABORTED
Definition: winerror.h:739
#define FD_ACCEPT
Definition: winsock.h:408
#define FD_CONNECT
Definition: winsock.h:409
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FD_READ
Definition: winsock.h:405
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define ERROR_IO_PENDING
Definition: dderror.h:15
BOOL WINAPI DestroyWindow(_In_ HWND)
#define FD_OOB
Definition: winsock.h:407
DWORD DWORD
Definition: winlogon.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FD_WRITE
Definition: winsock.h:406
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define closesocket
Definition: main.c:39
smooth NULL
Definition: ftsmooth.c:416
INT WSAAPI WSAAsyncSelect(IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent)
Definition: select.c:134
#define WM_SOCKET
Definition: sock.c:5505
#define ok(value,...)
Definition: CComObject.cpp:34
#define FD_CLOSE
Definition: winsock.h:410
ULONG len
Definition: ws2def.h:519
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define STATUS_CONNECTION_ABORTED
Definition: ntstatus.h:695
int ret
#define todo_wine
Definition: test.h:154
HKEY key
Definition: reg.c:42
CHAR FAR * buf
Definition: ws2def.h:520
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
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
#define WS_POPUP
Definition: pedump.c:616
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:537
#define WSAOVERLAPPED
Definition: winsock2.h:587
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
unsigned int ULONG
Definition: retypes.h:1
#define PM_REMOVE
Definition: winuser.h:1182
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
static void iocp_async_read_thread ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 11383 of file sock.c.

Referenced by test_iocp().

11384 {
11385  struct wsa_async_select_info select_info;
11386  struct wsa_recv_info recv_info;
11387  HANDLE port, thread;
11388  WSAOVERLAPPED *ovl_iocp;
11389  int ret;
11390  char data[512];
11391  DWORD bytes, tid;
11392  ULONG_PTR key;
11393  HWND hwnd;
11394  MSG msg;
11395 
11396  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11397  0, 0, 0, 0, NULL, NULL, 0, NULL);
11398  ok(hwnd != 0, "CreateWindowEx failed\n");
11399 
11400  select_info.sock = src;
11401  select_info.hwnd = hwnd;
11402  thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11403  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11404  ret = WaitForSingleObject(thread, 10000);
11405  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11406 
11407  Sleep(100);
11408  memset(&msg, 0, sizeof(msg));
11409  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11410  ok(ret, "got %d\n", ret);
11411  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11412  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11413  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11414  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11415 
11416  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11417  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11418 
11419  Sleep(100);
11420  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11421  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11422 
11423  memset(data, 0, sizeof(data));
11424  memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11425  recv_info.sock = src;
11426  recv_info.wsa_buf.len = sizeof(data);
11427  recv_info.wsa_buf.buf = data;
11428  thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11429  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11430  ret = WaitForSingleObject(thread, 10000);
11431  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11432 
11433  Sleep(100);
11434  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11435  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11436 
11437  bytes = 0xdeadbeef;
11438  key = 0xdeadbeef;
11439  ovl_iocp = (void *)0xdeadbeef;
11440  SetLastError(0xdeadbeef);
11441  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11442  ok(!ret, "got %d\n", ret);
11443  ok(GetLastError() == WAIT_TIMEOUT || broken(GetLastError() == ERROR_OPERATION_ABORTED) /* XP */, "got %u\n", GetLastError());
11444  if (GetLastError() == WAIT_TIMEOUT)
11445  {
11446  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11447  ok(key == 0xdeadbeef, "got key %lu\n", key);
11448  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11449  }
11450  else /* document XP behaviour */
11451  {
11452  ok(bytes == 0, "got bytes %u\n", bytes);
11453  ok(key == 0x12345678, "got key %#lx\n", key);
11454  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11455  if (ovl_iocp)
11456  {
11457  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11458  ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11459  }
11460  }
11461 
11462  Sleep(100);
11463  memset(&msg, 0, sizeof(msg));
11464  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11465  ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11466  if (ret) /* document XP behaviour */
11467  {
11468  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11469  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11470  ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11471  }
11472 
11473  ret = send(dst, "Hello World!", 12, 0);
11474  ok(ret == 12, "send returned %d\n", ret);
11475 
11476  Sleep(100);
11477  memset(&msg, 0, sizeof(msg));
11478  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11479  ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11480  if (ret) /* document XP behaviour */
11481  {
11482  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11483  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11484  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11485  ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11486  }
11487 
11488  bytes = 0xdeadbeef;
11489  key = 0xdeadbeef;
11490  ovl_iocp = (void *)0xdeadbeef;
11491  SetLastError(0xdeadbeef);
11492  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11493  ok(ret || broken(GetLastError() == WAIT_TIMEOUT) /* XP */, "got %u\n", GetLastError());
11494  if (ret)
11495  {
11496  ok(bytes == 12, "got bytes %u\n", bytes);
11497  ok(key == 0x12345678, "got key %#lx\n", key);
11498  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11499  if (ovl_iocp)
11500  {
11501  ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh);
11502  ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal);
11503  ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data);
11504  }
11505  }
11506  else /* document XP behaviour */
11507  {
11508  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11509  ok(key == 0xdeadbeef, "got key %lu\n", key);
11510  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11511  }
11512 
11513  CloseHandle(port);
11514 
11515  DestroyWindow(hwnd);
11516 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
DWORD DWORD
Definition: winlogon.h:84
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:231
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
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:112
smooth NULL
Definition: ftsmooth.c:416
#define WM_SOCKET
Definition: sock.c:5505
#define ok(value,...)
Definition: CComObject.cpp:34
#define WAIT_OBJECT_0
Definition: winbase.h:387
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
static DWORD WINAPI wsa_recv_thread(void *param)
Definition: sock.c:11238
#define WS_POPUP
Definition: pedump.c:616
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
static DWORD WINAPI wsa_async_select_thread(void *param)
Definition: sock.c:11220
#define WSAOVERLAPPED
Definition: winsock2.h:587
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define PM_REMOVE
Definition: winuser.h:1182
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
static TfClientId tid
static void iocp_async_read_thread_closesocket ( SOCKET  src)
static

Definition at line 11255 of file sock.c.

Referenced by test_iocp().

11256 {
11257  struct wsa_async_select_info select_info;
11258  struct wsa_recv_info recv_info;
11259  HANDLE port, thread;
11260  WSAOVERLAPPED *ovl_iocp;
11261  int ret;
11262  char data[512];
11263  DWORD bytes, tid;
11264  ULONG_PTR key;
11265  HWND hwnd;
11266  MSG msg;
11267 
11268  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11269  0, 0, 0, 0, NULL, NULL, 0, NULL);
11270  ok(hwnd != 0, "CreateWindowEx failed\n");
11271 
11272  select_info.sock = src;
11273  select_info.hwnd = hwnd;
11274  thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11275  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11276  ret = WaitForSingleObject(thread, 10000);
11277  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11278 
11279  Sleep(100);
11280  memset(&msg, 0, sizeof(msg));
11281  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11282  ok(ret, "got %d\n", ret);
11283  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11284  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11285  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11286  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11287 
11288  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11289  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11290 
11291  Sleep(100);
11292  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11293  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11294 
11295  memset(data, 0, sizeof(data));
11296  memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11297  recv_info.sock = src;
11298  recv_info.wsa_buf.len = sizeof(data);
11299  recv_info.wsa_buf.buf = data;
11300  thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11301  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11302  ret = WaitForSingleObject(thread, 10000);
11303  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11304 
11305  Sleep(100);
11306  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11307  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11308 
11309  bytes = 0xdeadbeef;
11310  key = 0xdeadbeef;
11311  ovl_iocp = (void *)0xdeadbeef;
11312  SetLastError(0xdeadbeef);
11313  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11314  ok(!ret, "got %d\n", ret);
11316  "got %u\n", GetLastError());
11317  if (GetLastError() == WAIT_TIMEOUT)
11318  {
11319  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11320  ok(key == 0xdeadbeef, "got key %lx\n", key);
11321  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11322  }
11323  else /* document XP behaviour */
11324  {
11325  ok(!bytes, "got bytes %u\n", bytes);
11326  ok(key == 0x12345678, "got key %#lx\n", key);
11327  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11328  if (ovl_iocp)
11329  {
11330  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11331  ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11332  }
11333 
11334  closesocket(src);
11335  goto xp_is_broken;
11336  }
11337 
11338  Sleep(100);
11339  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11340  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11341 
11342  closesocket(src);
11343 
11344  Sleep(100);
11345  ret = PeekMessageA(&msg, hwnd, WM_SOCKET, WM_SOCKET, PM_REMOVE);
11346  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11347 
11348  bytes = 0xdeadbeef;
11349  key = 0xdeadbeef;
11350  ovl_iocp = NULL;
11351  SetLastError(0xdeadbeef);
11352  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11353  ok(!ret, "got %d\n", ret);
11354 todo_wine
11356  ok(!bytes, "got bytes %u\n", bytes);
11357  ok(key == 0x12345678, "got key %#lx\n", key);
11358  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11359  if (ovl_iocp)
11360  {
11361  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11362 todo_wine
11363  ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11364  }
11365 
11366 xp_is_broken:
11367  bytes = 0xdeadbeef;
11368  key = 0xdeadbeef;
11369  ovl_iocp = (void *)0xdeadbeef;
11370  SetLastError(0xdeadbeef);
11371  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11372  ok(!ret, "got %d\n", ret);
11373  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11374  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11375  ok(key == 0xdeadbeef, "got key %lu\n", key);
11376  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11377 
11378  CloseHandle(port);
11379 
11380  DestroyWindow(hwnd);
11381 }
#define ERROR_NETNAME_DELETED
Definition: winerror.h:156
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define ERROR_CONNECTION_ABORTED
Definition: winerror.h:739
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:114
HANDLE HWND
Definition: compat.h:13
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
DWORD DWORD
Definition: winlogon.h:84
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:231
uint32_t ULONG_PTR
Definition: typedefs.h:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define closesocket
Definition: main.c:39
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:112
smooth NULL
Definition: ftsmooth.c:416
#define WM_SOCKET
Definition: sock.c:5505
#define ok(value,...)
Definition: CComObject.cpp:34
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define STATUS_CONNECTION_ABORTED
Definition: ntstatus.h:695
int ret
#define todo_wine
Definition: test.h:154
HKEY key
Definition: reg.c:42
#define broken(x)
Definition: _sntprintf.h:21
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
static DWORD WINAPI wsa_recv_thread(void *param)
Definition: sock.c:11238
#define WS_POPUP
Definition: pedump.c:616
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:537
static DWORD WINAPI wsa_async_select_thread(void *param)
Definition: sock.c:11220
#define WSAOVERLAPPED
Definition: winsock2.h:587
#define msg(x)
Definition: auth_time.c:54
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
unsigned int ULONG
Definition: retypes.h:1
#define PM_REMOVE
Definition: winuser.h:1182
USHORT port
Definition: uri.c:227
#define memset(x, y, z)
Definition: compat.h:39
static TfClientId tid
static int match_event_sequence ( SOCKET  s,
WSANETWORKEVENTS netEvents,
const LPARAM seq 
)
static

Definition at line 5669 of file sock.c.

Referenced by ok_event_sequence().

5670 {
5671  int event, index, error, events;
5672  struct async_message *curr;
5673 
5674  if (netEvents)
5675  {
5676  events = netEvents->lNetworkEvents;
5677  while (*seq)
5678  {
5679  event = WSAGETSELECTEVENT(*seq);
5680  error = WSAGETSELECTERROR(*seq);
5681  get_event_details(event, &index, NULL);
5682 
5683  if (!(events & event) && index != -1)
5684  return 0;
5685  if (events & event && index != -1)
5686  {
5687  if (netEvents->iErrorCode[index] != error)
5688  return 0;
5689  }
5690  events &= ~event;
5691  seq++;
5692  }
5693  if (events)
5694  return 0;
5695  }
5696  else
5697  {
5698  curr = messages_received;
5699  while (curr)
5700  {
5701  if (curr->socket == s)
5702  {
5703  if (!*seq) return 0;
5704  if (*seq != curr->lparam) return 0;
5705  seq++;
5706  }
5707  curr = curr->next;
5708  }
5709  if (*seq)
5710  return 0;
5711  }
5712  return 1;
5713 }
#define error(str)
Definition: mkdosfs.c:1605
struct async_message * next
Definition: sock.c:5500
SOCKET socket
Definition: sock.c:5498
static struct async_message * messages_received
Definition: sock.c:5503
LPARAM lparam
Definition: sock.c:5499
smooth NULL
Definition: ftsmooth.c:416
#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:5532
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 5716 of file sock.c.

5717 {
5718  MSG msg;
5719  WSANETWORKEVENTS events, *netEvents = NULL;
5720  int ret;
5721  DWORD dwRet;
5722 
5724  {
5725  netEvents = &events;
5726 
5727  dwRet = WaitForSingleObject(hEvent, 200);
5728  if (dwRet == WAIT_OBJECT_0)
5729  {
5730  ret = WSAEnumNetworkEvents(s, hEvent, netEvents);
5731  if (ret)
5732  {
5733  winetest_ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5734  return;
5735  }
5736  }
5737  else
5738  memset(netEvents, 0, sizeof(*netEvents));
5739  }
5740  else
5741  {
5742  Sleep(200);
5743  /* Run the message loop a little */
5744  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
5745  {
5746  DispatchMessageA(&msg);
5747  }
5748  }
5749 
5750  if (match_event_sequence(s, netEvents, seq))
5751  {
5752  winetest_ok(1, "Sequence matches expected: %s\n", dbgstr_event_seq(seq));
5753  flush_events(s, hEvent);
5754  return;
5755  }
5756 
5757  if (broken_seqs)
5758  {
5759  for (; *broken_seqs; broken_seqs++)
5760  {
5761  if (match_event_sequence(s, netEvents, *broken_seqs))
5762  {
5763  winetest_ok(broken(1), "Sequence matches broken: %s, expected %s\n", dbgstr_event_seq_result(s, netEvents), dbgstr_event_seq(seq));
5764  flush_events(s, hEvent);
5765  return;
5766  }
5767  }
5768  }
5769 
5770  winetest_ok(broken(completelyBroken), "Expected event sequence %s, got %s\n", dbgstr_event_seq(seq),
5771  dbgstr_event_seq_result(s, netEvents));
5772  flush_events(s, hEvent);
5773 }
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:5566
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:84
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:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
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:5585
GLdouble s
Definition: gl.h:2039
#define broken(x)
Definition: _sntprintf.h:21
static void flush_events(SOCKET s, HANDLE hEvent)
Definition: sock.c:5629
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:5669
#define PM_REMOVE
Definition: winuser.h:1182
#define memset(x, y, z)
Definition: compat.h:39
static VOID WINAPI oob_client ( client_params par)
static

Definition at line 922 of file sock.c.

923 {
924  test_params *gen = par->general;
926  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
927 
928  id = GetCurrentThreadId();
929  trace ( "oob_client (%x): starting\n", id );
930  /* wait here because we want to call set_so_opentype before creating a socket */
932  trace ( "oob_client (%x): server ready\n", id );
933 
935  set_so_opentype ( FALSE ); /* non-overlapped */
936  client_start ( par );
937  mem = TlsGetValue ( tls );
938 
939  /* Connect */
940  wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
941  0 ==, "oob_client (%x): connect error: %d\n" );
942  ok ( set_blocking ( mem->s, TRUE ) == 0,
943  "oob_client (%x): failed to set blocking mode\n", id );
944  trace ( "oob_client (%x) connected\n", id );
945 
946  /* send data to server */
947  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
948  ok ( n_sent == n_expected,
949  "oob_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
950 
951  /* Receive data echoed back & check it */
952  n_recvd = do_synchronous_recv ( mem->s, mem->recv_buf, n_expected, 0, par->buflen );
953  ok ( n_recvd == n_expected,
954  "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
955  pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
956  ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
957 
958  /* send out-of-band data to server */
959  n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, MSG_OOB, par->buflen );
960  ok ( n_sent == n_expected,
961  "oob_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
962 
963  /* shutdown send direction */
964  wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
965 
966  /* cleanup */
967  read_zero_bytes ( mem->s );
968  trace ( "oob_client (%x) exiting\n", id );
969  client_stop ();
970 }
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
test_params * general
Definition: sock.c:149
char * recv_buf
Definition: sock.c:178
static void check_so_opentype(void)
Definition: sock.c:437
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:356
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:421
#define ok(value,...)
Definition: CComObject.cpp:34
struct sockaddr_in addr
Definition: sock.c:176
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
SOCKET s
Definition: sock.c:175
int buflen
Definition: sock.c:151
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:343
static void read_zero_bytes(SOCKET s)
Definition: sock.c:385
static void client_start(client_params *par)
Definition: sock.c:567
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:369
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
#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:407
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
char * send_buf
Definition: sock.c:177
GLenum GLuint id
Definition: glext.h:5579
static DWORD tls
Definition: sock.c:230
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:394
static HANDLE server_ready
Definition: sock.c:233
#define INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:134
static void client_stop(void)
Definition: sock.c:594
static VOID WINAPI oob_server ( server_params par)
static

Definition at line 664 of file sock.c.

665 {
666  test_params *gen = par->general;
668  u_long atmark = 0;
669  int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, tmp,
670  id = GetCurrentThreadId();
671 
672  trace ( "oob_server (%x) starting\n", id );
673 
674  set_so_opentype ( FALSE ); /* non-overlapped */
675  server_start ( par );
676  mem = TlsGetValue ( tls );
677 
678  wsa_ok ( set_blocking ( mem->s, TRUE ), 0 ==, "oob_server (%x): failed to set blocking mode: %d\n");
679  wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "oob_server (%x): listen failed: %d\n");
680 
681  trace ( "oob_server (%x) ready\n", id );
682  SetEvent ( server_ready ); /* notify clients */
683 
684  trace ( "oob_server (%x): waiting for client\n", id );
685 
686  /* accept a single connection */
687  tmp = sizeof ( mem->sock[0].peer );
688  mem->sock[0].s = accept ( mem->s, (struct sockaddr*) &mem->sock[0].peer, &tmp );
689  wsa_ok ( mem->sock[0].s, INVALID_SOCKET !=, "oob_server (%x): accept failed: %d\n" );
690 
691  ok ( mem->sock[0].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
692  "oob_server (%x): strange peer address\n", id );
693 
694  /* check initial atmark state */
695  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
696  ok ( atmark == 1, "oob_server (%x): unexpectedly at the OOB mark: %i\n", id, atmark );
697 
698  /* Receive normal data */
699  n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
700  ok ( n_recvd == n_expected,
701  "oob_server (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
702  pos = test_buffer ( mem->sock[0].buf, gen->chunk_size, gen->n_chunks );
703  ok ( pos == -1, "oob_server (%x): test pattern error: %d\n", id, pos);
704 
705  /* check atmark state */
706  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
707  ok ( atmark == 1, "oob_server (%x): unexpectedly at the OOB mark: %i\n", id, atmark );
708 
709  /* Echo data back */
710  n_sent = do_synchronous_send ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
711  ok ( n_sent == n_expected,
712  "oob_server (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
713 
714  /* Receive a part of the out-of-band data and print atmark state */
715  n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, 8, 0, par->buflen );
716  ok ( n_recvd == 8,
717  "oob_server (%x): received less data than expected: %d of %d\n", id, n_recvd, 8 );
718  n_expected -= 8;
719 
720  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
721  trace( "oob_server (%x): %s the OOB mark: %i\n", id, atmark == 1 ? "not at" : "at", atmark );
722 
723  /* Receive the rest of the out-of-band data and check atmark state */
724  do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
725 
726  ioctlsocket ( mem->sock[0].s, SIOCATMARK, &atmark );
727  todo_wine ok ( atmark == 0, "oob_server (%x): not at the OOB mark: %i\n", id, atmark );
728 
729  /* cleanup */
730  wsa_ok ( closesocket ( mem->sock[0].s ), 0 ==, "oob_server (%x): closesocket error: %d\n" );
731  mem->sock[0].s = INVALID_SOCKET;
732 
733  trace ( "oob_server (%x) exiting\n", id );
734  server_stop ();
735 }
#define trace(...)
Definition: kmt_test.h:217
#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:356
SOCKET s
Definition: sock.c:118
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
char * buf
Definition: sock.c:121
#define SOMAXCONN
Definition: winsock.h:399
#define closesocket
Definition: main.c:39
#define FALSE
Definition: types.h:117
static void server_start(server_params *par)
Definition: sock.c:522
SOCKET s
Definition: sock.c:167
test_params * general
Definition: sock.c:141
#define ioctlsocket
Definition: main.c:40
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define ok(value,...)
Definition: CComObject.cpp:34
#define INVALID_SOCKET
Definition: winsock.h:332
const char * inet_addr
Definition: sock.c:131
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:343
#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:143
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:369
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
struct sockaddr_in peer
Definition: sock.c:120
sock_info sock[MAX_CLIENTS]
Definition: sock.c:169
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:407
static void server_stop(void)
Definition: sock.c:549
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
static DWORD tls
Definition: sock.c:230
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:394
static HANDLE server_ready
Definition: sock.c:233
int n_chunks
Definition: sock.c:134
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 7115 of file sock.c.

7116 {
7117  int k;
7118  for (k = 0; k < max; k++)
7119  if (fds[k].fd == s && (fds[k].revents == rev)) return TRUE;
7120  return FALSE;
7121 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
static int fd
Definition: io.c:51
#define FALSE
Definition: types.h:117
int rev
Definition: sort.c:17
GLdouble s
Definition: gl.h:2039
int k
Definition: mpi.c:3369
static void read_zero_bytes ( SOCKET  s)
static

Definition at line 385 of file sock.c.

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

386 {
387  char buf[256];
388  int tmp, n = 0;
389  while ( ( tmp = recv ( s, buf, 256, 0 ) ) > 0 )
390  n += tmp;
391  ok ( n <= 0, "garbage data received: %d bytes\n", n );
392 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint n
Definition: s_context.h:57
#define ok(value,...)
Definition: CComObject.cpp:34
GLdouble s
Definition: gl.h:2039
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 6721 of file sock.c.

Referenced by test_WSARecv().

6722 {
6723  SOCKET sock = *(SOCKET *)arg;
6724  char buffer[32];
6725  WSABUF wsa;
6726  WSAOVERLAPPED ov;
6727  DWORD flags = 0;
6728 
6729  wsa.buf = buffer;
6730  wsa.len = sizeof(buffer);
6731  ov.hEvent = WSACreateEvent();
6732  WSARecv(sock, &wsa, 1, NULL, &flags, &ov, NULL);
6733 
6734  WaitForSingleObject(ov.hEvent, 1000);
6735  WSACloseEvent(ov.hEvent);
6736  return 0;
6737 }
GLuint buffer
Definition: glext.h:5915
DWORD DWORD
Definition: winlogon.h:84
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:416
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 740 of file sock.c.

741 {
742  test_params *gen = par->general;
744  int n_expected = gen->n_chunks * gen->chunk_size, tmp, i,
745  id = GetCurrentThreadId(), n_connections = 0, n_sent, n_recvd,
746  n_set, delta, n_ready;
747  struct timeval timeout = {0,10}; /* wait for 10 milliseconds */
748  fd_set fds_recv, fds_send, fds_openrecv, fds_opensend;
749 
750  trace ( "select_server (%x) starting\n", id );
751 
752  set_so_opentype ( FALSE ); /* non-overlapped */
753  server_start ( par );
754  mem = TlsGetValue ( tls );
755 
756  wsa_ok ( set_blocking ( mem->s, FALSE ), 0 ==, "select_server (%x): failed to set blocking mode: %d\n");
757  wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "select_server (%x): listen failed: %d\n");
758 
759  trace ( "select_server (%x) ready\n", id );
760  SetEvent ( server_ready ); /* notify clients */
761 
762  FD_ZERO ( &fds_openrecv );
763  FD_ZERO ( &fds_recv );
764  FD_ZERO ( &fds_send );
765  FD_ZERO ( &fds_opensend );
766 
767  FD_SET ( mem->s, &fds_openrecv );
768 
769  while(1)
770  {
771  fds_recv = fds_openrecv;
772  fds_send = fds_opensend;
773 
774  n_set = 0;
775 
776  wsa_ok ( ( n_ready = select ( 0, &fds_recv, &fds_send, NULL, &timeout ) ), SOCKET_ERROR !=,
777  "select_server (%x): select() failed: %d\n" );
778 
779  /* check for incoming requests */
780  if ( FD_ISSET ( mem->s, &fds_recv ) ) {
781  n_set += 1;
782 
783  trace ( "select_server (%x): accepting client connection\n", id );
784 
785  /* accept a single connection */
786  tmp = sizeof ( mem->sock[n_connections].peer );
787  mem->sock[n_connections].s = accept ( mem->s, (struct sockaddr*) &mem->sock[n_connections].peer, &tmp );
788  wsa_ok ( mem->sock[n_connections].s, INVALID_SOCKET !=, "select_server (%x): accept() failed: %d\n" );
789 
790  ok ( mem->sock[n_connections].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
791  "select_server (%x): strange peer address\n", id );
792 
793  /* add to list of open connections */
794  FD_SET ( mem->sock[n_connections].s, &fds_openrecv );
795  FD_SET ( mem->sock[n_connections].s, &fds_opensend );
796 
797  n_connections++;
798  }
799 
800  /* handle open requests */
801 
802  for ( i = 0; i < n_connections; i++ )
803  {
804  if ( FD_ISSET( mem->sock[i].s, &fds_recv ) ) {
805  n_set += 1;
806 
807  if ( mem->sock[i].n_recvd < n_expected ) {
808  /* Receive data & check it */
809  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 );
810  ok ( n_recvd != SOCKET_ERROR, "select_server (%x): error in recv(): %d\n", id, WSAGetLastError() );
811  mem->sock[i].n_recvd += n_recvd;
812 
813  if ( mem->sock[i].n_recvd == n_expected ) {
814  int pos = test_buffer ( mem->sock[i].buf, gen->chunk_size, gen->n_chunks );
815  ok ( pos == -1, "select_server (%x): test pattern error: %d\n", id, pos );
816  FD_CLR ( mem->sock[i].s, &fds_openrecv );
817  }
818 
819  ok ( mem->sock[i].n_recvd <= n_expected, "select_server (%x): received too many bytes: %d\n", id, mem->sock[i].n_recvd );
820  }
821  }
822 
823  /* only echo back what we've received */
824  delta = mem->sock[i].n_recvd - mem->sock[i].n_sent;
825 
826  if ( FD_ISSET ( mem->sock[i].s, &fds_send ) ) {
827  n_set += 1;
828 
829  if ( ( delta > 0 ) && ( mem->sock[i].n_sent < n_expected ) ) {
830  /* Echo data back */
831  n_sent = send ( mem->sock[i].s, mem->sock[i].buf + mem->sock[i].n_sent, min ( delta, par->buflen ), 0 );
832  ok ( n_sent != SOCKET_ERROR, "select_server (%x): error in send(): %d\n", id, WSAGetLastError() );
833  mem->sock[i].n_sent += n_sent;
834 
835  if ( mem->sock[i].n_sent == n_expected ) {
836  FD_CLR ( mem->sock[i].s, &fds_opensend );
837  }
838 
839  ok ( mem->sock[i].n_sent <= n_expected, "select_server (%x): sent too many bytes: %d\n", id, mem->sock[i].n_sent );
840  }
841  }
842  }
843 
844  /* check that select returned the correct number of ready sockets */
845  ok ( ( n_set == n_ready ), "select_server (%x): select() returns wrong number of ready sockets\n", id );
846 
847  /* check if all clients are done */
848  if ( ( fds_opensend.fd_count == 0 )
849  && ( fds_openrecv.fd_count == 1 ) /* initial socket that accepts clients */
850  && ( n_connections == min ( gen->n_clients, MAX_CLIENTS ) ) ) {
851  break;
852  }
853  }
854 
855  for ( i = 0; i < min ( gen->n_clients, MAX_CLIENTS ); i++ )
856  {
857  /* cleanup */
858  read_zero_bytes ( mem->sock[i].s );
859  wsa_ok ( closesocket ( mem->sock[i].s ), 0 ==, "select_server (%x): closesocket error: %d\n" );
860  mem->sock[i].s = INVALID_SOCKET;
861  }
862 
863  trace ( "select_server (%x) exiting\n", id );
864  server_stop ();
865 }
Definition: winsock.h:66
#define SOCKET_ERROR
Definition: winsock.h:333
#define trace(...)
Definition: kmt_test.h:217
#define inet_addr(cp)
Definition: inet.h:98
int n_recvd
Definition: sock.c:122
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:356
SOCKET s
Definition: sock.c:118
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:121
int n_sent
Definition: sock.c:123
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define SOMAXCONN
Definition: winsock.h:399
#define closesocket
Definition: main.c:39
#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:522
SOCKET s
Definition: sock.c:167
smooth NULL
Definition: ftsmooth.c:416
test_params * general
Definition: sock.c:141
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define ok(value,...)
Definition: CComObject.cpp:34
#define MAX_CLIENTS
Definition: sock.c:46
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:131
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:343
static void read_zero_bytes(SOCKET s)
Definition: sock.c:385
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
int buflen
Definition: sock.c:143
static int test_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:369
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
struct sockaddr_in peer
Definition: sock.c:120
int n_clients
Definition: sock.c:135
sock_info sock[MAX_CLIENTS]
Definition: sock.c:169
#define min(a, b)
Definition: monoChain.cc:55
static void server_stop(void)
Definition: sock.c:549
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
#define FD_CLR(fd, set)
Definition: winsock.h:74
static DWORD tls
Definition: sock.c:230
static HANDLE server_ready
Definition: sock.c:233
int n_chunks
Definition: sock.c:134
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 3650 of file sock.c.

Referenced by test_select(), and test_WSAPoll().

3651 {
3652  SOCKET s = *(SOCKET*)param;
3653  Sleep(500);
3654  closesocket(s);
3655  return 0;
3656 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define closesocket
Definition: main.c:39
GLdouble s
Definition: gl.h:2039
UINT_PTR SOCKET
Definition: winsock.h:47
static DWORD WINAPI SelectReadThread ( void param)
static

Definition at line 3623 of file sock.c.

Referenced by test_select().

3624 {
3625  select_thread_params *par = param;
3626  fd_set readfds;
3627  int ret;
3628  struct sockaddr_in addr;
3629  struct timeval select_timeout;
3630 
3631  memset(&readfds, 0, sizeof(readfds));
3632  FD_ZERO(&readfds);
3633  FD_SET(par->s, &readfds);
3634  select_timeout.tv_sec=5;
3635  select_timeout.tv_usec=0;
3636  addr.sin_family = AF_INET;
3637  addr.sin_addr.s_addr = inet_addr(SERVERIP);
3638  addr.sin_port = htons(SERVERPORT);
3639 
3640  do_bind(par->s, (struct sockaddr *)&addr, sizeof(addr));
3641  wsa_ok(listen(par->s, SOMAXCONN ), 0 ==, "SelectReadThread (%x): listen failed: %d\n");
3642 
3644  ret = select(par->s+1, &readfds, NULL, NULL, &select_timeout);
3645  par->ReadKilled = (ret == 1);
3646 
3647  return 0;
3648 }
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:416
GLfloat param
Definition: glext.h:5796
#define SERVERPORT
Definition: sock.c:59
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
#define wsa_ok(op, cond, msg)
Definition: sock.c:61
static void do_bind(SOCKET s, struct sockaddr *addr, int addrlen)
Definition: sock.c:508
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:58
static HANDLE server_ready
Definition: sock.c:233
#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 522 of file sock.c.

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

523 {
524  int i;
525  test_params *gen = par->general;
526  server_memory *mem = LocalAlloc ( LPTR, sizeof ( server_memory ) );
527 
528  TlsSetValue ( tls, mem );
529  mem->s = WSASocketA ( AF_INET, gen->sock_type, gen->sock_prot,
530  NULL, 0, par->sock_flags );
531  ok ( mem->s != INVALID_SOCKET, "Server: WSASocket failed\n" );
532 
533  mem->addr.sin_family = AF_INET;
534  mem->addr.sin_addr.s_addr = inet_addr ( gen->inet_addr );
535  mem->addr.sin_port = htons ( gen->inet_port );
536 
537  for (i = 0; i < MAX_CLIENTS; i++)
538  {
539  mem->sock[i].s = INVALID_SOCKET;
540  mem->sock[i].buf = LocalAlloc ( LPTR, gen->n_chunks * gen->chunk_size );
541  mem->sock[i].n_recvd = 0;
542  mem->sock[i].n_sent = 0;
543  }
544 
545  if ( gen->sock_type == SOCK_STREAM )
546  do_bind ( mem->s, (struct sockaddr*) &mem->addr, sizeof (mem->addr) );
547 }
#define inet_addr(cp)
Definition: inet.h:98
int n_recvd
Definition: sock.c:122
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1199
SOCKET s
Definition: sock.c:118
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:121
int n_sent
Definition: sock.c:123
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int sock_prot
Definition: sock.c:130
SOCKET s
Definition: sock.c:167
smooth NULL
Definition: ftsmooth.c:416
test_params * general
Definition: sock.c:141
int sock_type
Definition: sock.c:129
#define ok(value,...)
Definition: CComObject.cpp:34
#define MAX_CLIENTS
Definition: sock.c:46
#define INVALID_SOCKET
Definition: winsock.h:332
const char * inet_addr
Definition: sock.c:131
short inet_port
Definition: sock.c:132
static void do_bind(SOCKET s, struct sockaddr *addr, int addrlen)
Definition: sock.c:508
sock_info sock[MAX_CLIENTS]
Definition: sock.c:169
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
#define AF_INET
Definition: tcpip.h:117
#define LPTR
Definition: winbase.h:362
struct sockaddr_in addr
Definition: sock.c:168
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
static DWORD tls
Definition: sock.c:230
#define SOCK_STREAM
Definition: tcpip.h:118
#define htons(x)
Definition: module.h:213
int n_chunks
Definition: sock.c:134
DWORD sock_flags
Definition: sock.c:142
static void server_stop ( void  )
static

Definition at line 549 of file sock.c.

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

550 {
551  int i;
553 
554  for (i = 0; i < MAX_CLIENTS; i++ )
555  {
556  LocalFree ( mem->sock[i].buf );
557  if ( mem->sock[i].s != INVALID_SOCKET )
558  closesocket ( mem->sock[i].s );
559  }
560  ok ( closesocket ( mem->s ) == 0, "closesocket failed\n" );
561  LocalFree ( mem );
563 }
SOCKET s
Definition: sock.c:118
char * buf
Definition: sock.c:121
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define closesocket
Definition: main.c:39
SOCKET s
Definition: sock.c:167
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:327
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define ok(value,...)
Definition: CComObject.cpp:34
#define MAX_CLIENTS
Definition: sock.c:46
#define INVALID_SOCKET
Definition: winsock.h:332
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
sock_info sock[MAX_CLIENTS]
Definition: sock.c:169
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
Definition: mem.c:156
static DWORD tls
Definition: sock.c:230
static int set_blocking ( SOCKET  s,
BOOL  blocking 
)
static
static void set_so_opentype ( BOOL  overlapped)
static

Definition at line 343 of file sock.c.

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

344 {
345  int optval = !overlapped, newval, len = sizeof (int);
346 
348  (LPVOID) &optval, sizeof (optval) ) == 0,
349  "setting SO_OPENTYPE failed\n" );
351  (LPVOID) &newval, &len ) == 0,
352  "getting SO_OPENTYPE failed\n" );
353  ok ( optval == newval, "failed to set SO_OPENTYPE\n" );
354 }
#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 ok(value,...)
Definition: CComObject.cpp:34
#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:82
#define SO_OPENTYPE
Definition: ws2_32.h:40
static int(WINAPI *pgetaddrinfo)(LPCSTR
static SOCKET setup_connector_socket ( struct sockaddr_in addr,
int  len,
BOOL  nonblock 
)
static

Definition at line 4229 of file sock.c.

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

4230 {
4231  int ret;
4232  SOCKET connector;
4233 
4234  connector = socket(AF_INET, SOCK_STREAM, 0);
4235  ok(connector != INVALID_SOCKET, "failed to create connector socket %d\n", WSAGetLastError());
4236 
4237  if (nonblock)
4238  set_blocking(connector, !nonblock);
4239 
4240  ret = connect(connector, (struct sockaddr *)addr, len);
4241  if (!nonblock)
4242  ok(!ret, "connecting to accepting socket failed %d\n", WSAGetLastError());
4243  else if (ret == SOCKET_ERROR)
4244  {
4246  ok(error == WSAEWOULDBLOCK || error ==