ReactOS  0.4.15-dev-5615-gc3644fd
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 WCHARservname
 
namespace GUIDnamespace_id
 
namespace GUID const ADDRINFOEXW * hints
 
namespace GUID const ADDRINFOEXW ADDRINFOEXW ** result
 
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timevaltimeout
 
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPEDoverlapped
 
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine
 
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLEhandle
 
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

◆ BIND_SLEEP

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

Definition at line 48 of file sock.c.

◆ BIND_TRIES

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

Definition at line 49 of file sock.c.

◆ compare_file

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

Definition at line 8830 of file sock.c.

◆ FD_SET_ALL

#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.

◆ FD_ZERO_ALL

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

Definition at line 3780 of file sock.c.

◆ FIRST_CHAR

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

Definition at line 47 of file sock.c.

◆ IP_PKTINFO_LEN

Definition at line 2003 of file sock.c.

◆ make_keepalive

#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.

◆ MAX_CLIENTS

#define MAX_CLIENTS   4 /* Max number of clients */

Definition at line 46 of file sock.c.

◆ NUM_QUERIES

#define NUM_QUERIES   250 /* Number of getservbyname queries per thread */

Definition at line 56 of file sock.c.

◆ NUM_THREADS

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

Definition at line 55 of file sock.c.

◆ NUM_UDP_PEERS

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

Definition at line 53 of file sock.c.

◆ ok_event_seq

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

Definition at line 5776 of file sock.c.

◆ POLL_CLEAR

#define POLL_CLEAR ( )    ix = 0

Definition at line 7113 of file sock.c.

◆ POLL_ISSET

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

Definition at line 7115 of file sock.c.

◆ POLL_SET

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

Definition at line 7114 of file sock.c.

◆ SERVERIP

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

Definition at line 58 of file sock.c.

◆ SERVERPORT

#define SERVERPORT   9374 /* Port number to bind to */

Definition at line 59 of file sock.c.

◆ SOCKTIMEOUT1

#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.

◆ SOCKTIMEOUT2

#define SOCKTIMEOUT2   997000 /* 997 seconds */

Definition at line 1408 of file sock.c.

◆ STD_STREAM_SOCKET

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

Definition at line 2186 of file sock.c.

◆ TEST_TIMEOUT

#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.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 30 of file sock.c.

◆ WM_ASYNCCOMPLETE

#define WM_ASYNCCOMPLETE   (WM_USER + 100)

Definition at line 9496 of file sock.c.

◆ WM_SOCKET

#define WM_SOCKET   (WM_USER+100)

Definition at line 5506 of file sock.c.

◆ WSA_CMSG_ALIGN

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

Definition at line 44 of file sock.c.

◆ wsa_ok

#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);
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
UINT op
Definition: effect.c:236
#define err(...)
#define msg(x)
Definition: auth_time.c:54

Definition at line 61 of file sock.c.

Typedef Documentation

◆ async_message

◆ client_memory

◆ client_params

◆ select_thread_params

◆ server_memory

◆ server_params

◆ sock_info

◆ test_params

◆ test_setup

◆ thread_info

Function Documentation

◆ AcceptKillThread()

static DWORD WINAPI AcceptKillThread ( void param)
static

Definition at line 4160 of file sock.c.

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:733
#define closesocket
Definition: ncftp.h:477
#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

Referenced by test_accept().

◆ AlwaysDeferConditionFunc()

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.

4179 {
4180  return CF_DEFER;
4181 }
#define CF_DEFER
Definition: winsock2.h:415

Referenced by test_accept(), and test_AcceptEx().

◆ check_so_opentype()

static void check_so_opentype ( void  )
static

Definition at line 437 of file sock.c.

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 INVALID_SOCKET
Definition: winsock.h:332
GLenum GLsizei len
Definition: glext.h:6722
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
#define SO_OPENTYPE
Definition: ws2_32.h:40
#define ok(value,...)
Definition: atltest.h:57

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

◆ client_start()

static void client_start ( client_params par)
static

Definition at line 567 of file sock.c.

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 }
test_params * general
Definition: sock.c:149
#define inet_addr(cp)
Definition: inet.h:98
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
#define TRUE
Definition: types.h:120
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:733
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
int sock_type
Definition: sock.c:129
#define MAX_CLIENTS
Definition: sock.c:46
#define INVALID_SOCKET
Definition: winsock.h:332
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
#define htons(x)
Definition: module.h:213
DWORD sock_flags
Definition: sock.c:150
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
#define AF_INET
Definition: tcpip.h:117
#define LPTR
Definition: winbase.h:381
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 INFINITE
Definition: serial.h:102
int n_chunks
Definition: sock.c:134

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

◆ client_stop()

static void client_stop ( void  )
static

Definition at line 594 of file sock.c.

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: ncftp.h:477
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
#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:1240
Definition: mem.c:156
static DWORD tls
Definition: sock.c:230

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

◆ compare_addrinfo()

static void compare_addrinfo ( ADDRINFO a,
ADDRINFO b 
)
static

Definition at line 445 of file sock.c.

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
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by test_getaddrinfo().

◆ compare_addrinfow()

static void compare_addrinfow ( ADDRINFOW a,
ADDRINFOW b 
)
static

Definition at line 473 of file sock.c.

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
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by test_GetAddrInfoW().

◆ compare_file2()

static void compare_file2 ( HANDLE  handle,
SOCKET  sock,
int  offset,
const char file,
int  line 
)
static

Definition at line 8832 of file sock.c.

8833 {
8834  char buf1[256], buf2[256];
8835  BOOL success;
8836  int i = 0;
8837 
8839  while (1)
8840  {
8841  DWORD n1 = 0, n2 = 0;
8842 
8843  success = ReadFile(handle, buf1, sizeof(buf1), &n1, NULL);
8844  ok_(file,line)(success, "Failed to read from file.\n");
8845  if (success && n1 == 0)
8846  break;
8847  else if(!success)
8848  return;
8849  n2 = recv(sock, buf2, n1, 0);
8850  ok_(file,line)(n1 == n2, "Block %d size mismatch (%d != %d)\n", i, n1, n2);
8851  ok_(file,line)(memcmp(buf1, buf2, n2) == 0, "Block %d failed\n", i);
8852  i++;
8853  }
8854 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define FILE_BEGIN
Definition: compat.h:761
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: parser.c:48
GLintptr offset
Definition: glext.h:5920
unsigned long DWORD
Definition: ntddk_ex.h:95
#define success(from, fromstr, to, tostr)
int n1
Definition: dwarfget.c:148
int n2
Definition: dwarfget.c:148
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define NULL
Definition: types.h:112
Definition: tcpcore.h:1455
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define SetFilePointer
Definition: compat.h:743
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: fci.c:126

◆ create_async_message_window()

static HWND create_async_message_window ( void  )
static

Definition at line 9497 of file sock.c.

9498 {
9499  static const char class_name[] = "ws2_32 async message window class";
9500 
9501  WNDCLASSEXA wndclass;
9502  HWND hWnd;
9503 
9504  wndclass.cbSize = sizeof(wndclass);
9505  wndclass.style = CS_HREDRAW | CS_VREDRAW;
9506  wndclass.lpfnWndProc = DefWindowProcA;
9507  wndclass.cbClsExtra = 0;
9508  wndclass.cbWndExtra = 0;
9509  wndclass.hInstance = GetModuleHandleA(NULL);
9510  wndclass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION);
9512  wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
9513  wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
9514  wndclass.lpszClassName = class_name;
9515  wndclass.lpszMenuName = NULL;
9516 
9517  RegisterClassExA(&wndclass);
9518 
9519  hWnd = CreateWindowA(class_name, "ws2_32 async message window", WS_OVERLAPPEDWINDOW,
9520  0, 0, 500, 500, NULL, NULL, GetModuleHandleA(NULL), NULL);
9521  if (!hWnd)
9522  {
9523  ok(0, "failed to create window: %u\n", GetLastError());
9524  return NULL;
9525  }
9526 
9527  return hWnd;
9528 }
UINT style
Definition: winuser.h:3192
LPCSTR lpszMenuName
Definition: winuser.h:3200
HCURSOR hCursor
Definition: winuser.h:3198
WNDPROC lpfnWndProc
Definition: winuser.h:3193
LPCSTR lpszClassName
Definition: winuser.h:3201
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define CS_HREDRAW
Definition: winuser.h:648
#define IDI_APPLICATION
Definition: winuser.h:699
HICON hIconSm
Definition: winuser.h:3202
#define COLOR_WINDOW
Definition: winuser.h:912
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
HINSTANCE hInstance
Definition: winuser.h:3196
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4305
UINT cbSize
Definition: winuser.h:3191
const char * LPCSTR
Definition: xmlstorage.h:183
HBRUSH hbrBackground
Definition: winuser.h:3199
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3195
HICON hIcon
Definition: winuser.h:3197
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
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:3194
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

Referenced by test_WSAAsyncGetServByName(), and test_WSAAsyncGetServByPort().

◆ dbgstr_event_seq()

static const char* dbgstr_event_seq ( const LPARAM seq)
static

Definition at line 5567 of file sock.c.

5568 {
5569  static char message[1024];
5570  char name[12];
5571  int len = 1;
5572 
5573  message[0] = '[';
5574  message[1] = 0;
5575  while (*seq)
5576  {
5578  len += sprintf(message + len, "%s(%d) ", name, WSAGETSELECTERROR(*seq));
5579  seq++;
5580  }
5581  if (len > 1) len--;
5582  strcpy( message + len, "]" );
5583  return message;
5584 }
Definition: tftpd.h:59
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
GLenum GLsizei len
Definition: glext.h:6722
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
#define NULL
Definition: types.h:112
Definition: name.c:38
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:5533

Referenced by ok_event_sequence().

◆ dbgstr_event_seq_result()

static char* dbgstr_event_seq_result ( SOCKET  s,
WSANETWORKEVENTS netEvents 
)
static

Definition at line 5586 of file sock.c.

5587 {
5588  static char message[1024];
5589  struct async_message *curr = messages_received;
5590  int index, error, bit = 0;
5591  char name[12];
5592  int len = 1;
5593 
5594  message[0] = '[';
5595  message[1] = 0;
5596  while (1)
5597  {
5598  if (netEvents)
5599  {
5600  if (bit >= FD_MAX_EVENTS) break;
5601  if ( !(netEvents->lNetworkEvents & (1 << bit)) )
5602  {
5603  bit++;
5604  continue;
5605  }
5606  get_event_details(1 << bit, &index, name);
5607  error = netEvents->iErrorCode[index];
5608  bit++;
5609  }
5610  else
5611  {
5612  if (!curr) break;
5613  if (curr->socket != s)
5614  {
5615  curr = curr->next;
5616  continue;
5617  }
5619  error = WSAGETSELECTERROR(curr->lparam);
5620  curr = curr->next;
5621  }
5622 
5623  len += sprintf(message + len, "%s(%d) ", name, error);
5624  }
5625  if (len > 1) len--;
5626  strcpy( message + len, "]" );
5627  return message;
5628 }
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:5501
SOCKET socket
Definition: sock.c:5499
static struct async_message * messages_received
Definition: sock.c:5504
#define sprintf(buf, format,...)
Definition: sprintf.c:55
LPARAM lparam
Definition: sock.c:5500
GLuint index
Definition: glext.h:6031
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
#define NULL
Definition: types.h:112
Definition: name.c:38
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:5533

Referenced by ok_event_sequence().

◆ do_bind()

static void do_bind ( SOCKET  s,
struct sockaddr addr,
int  addrlen 
)
static

Definition at line 508 of file sock.c.

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 BIND_SLEEP
Definition: sock.c:48
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
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
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define trace
Definition: atltest.h:70
GLenum const GLvoid * addr
Definition: glext.h:9621
GLdouble s
Definition: gl.h:2039
#define err(...)
#define ok(value,...)
Definition: atltest.h:57
#define WSAEADDRINUSE
Definition: winerror.h:1961

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

◆ do_getservbyname()

static DWORD WINAPI do_getservbyname ( void param)
static

Definition at line 2349 of file sock.c.

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
#define TEST_TIMEOUT
Definition: sock.c:50
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static const CHAR s_name[]
Definition: ShowWindow.c:19
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
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
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ntohs(x)
Definition: module.h:208
#define broken(x)
Definition: _sntprintf.h:21
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define htons(x)
Definition: module.h:213
#define ok(value,...)
Definition: atltest.h:57
short s_port
Definition: winsock.h:165
#define NULL
Definition: types.h:112
Definition: name.c:38
char * s_proto
Definition: winsock.h:166
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
USHORT port
Definition: uri.c:228
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_getservbyname().

◆ do_synchronous_recv()

static int do_synchronous_recv ( SOCKET  s,
char buf,
int  buflen,
int  flags,
int  recvlen 
)
static

Definition at line 407 of file sock.c.

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 }
POINT last
Definition: font.c:46
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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

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

◆ do_synchronous_recvfrom()

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.

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
POINT last
Definition: font.c:46
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
CardRegion * from
Definition: spigame.cpp:19

Referenced by simple_mixed_client().

◆ do_synchronous_send()

static int do_synchronous_send ( SOCKET  s,
char buf,
int  buflen,
int  flags,
int  sendlen 
)
static

Definition at line 394 of file sock.c.

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 }
POINT last
Definition: font.c:46
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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

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

◆ do_test()

static void do_test ( test_setup test)
static

Definition at line 1363 of file sock.c.

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 CloseHandle
Definition: compat.h:739
#define TEST_TIMEOUT
Definition: sock.c:50
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:587
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
static void StartClients(LPTHREAD_START_ROUTINE routine, test_params *general, client_params *par)
Definition: sock.c:1348
#define test
Definition: rosglue.h:37
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:231
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define MAX_CLIENTS
Definition: sock.c:46
#define WAIT_OBJECT_0
Definition: winbase.h:406
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:232
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:234
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
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

Referenced by START_TEST().

◆ drain_socket_thread()

static DWORD WINAPI drain_socket_thread ( LPVOID  arg)
static

Definition at line 5330 of file sock.c.

5331 {
5332  char buffer[1024];
5333  SOCKET sock = *(SOCKET*)arg;
5334  int ret;
5335 
5336  while ((ret = recv(sock, buffer, sizeof(buffer), 0)) != 0)
5337  {
5338  if (ret < 0)
5339  {
5341  {
5342  fd_set readset;
5343  FD_ZERO(&readset);
5344  FD_SET(sock, &readset);
5345  select(sock+1, &readset, NULL, NULL, NULL);
5346  while (drain_pause)
5347  Sleep(100);
5348  }
5349  else
5350  break;
5351  }
5352  }
5353  return 0;
5354 }
Definition: winsock.h:66
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#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
static BOOL drain_pause
Definition: sock.c:5329
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
int ret
#define NULL
Definition: types.h:112
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

Referenced by test_events(), and test_send().

◆ DWORD()

static DWORD ( WINAPI pGetAdaptersInfo)
static

◆ event_client()

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 ();
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  {
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 }
test_params * general
Definition: sock.c:149
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define FD_CONNECT
Definition: winsock.h:409
#define TRUE
Definition: types.h:120
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLdouble n
Definition: glext.h:7729
#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
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:459
#define FD_CLOSE_BIT
Definition: winsock2.h:303
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define FD_CLOSE
Definition: winsock.h:410
#define trace
Definition: atltest.h:70
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
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
WSAEVENT WSAAPI WSACreateEvent(VOID)
Definition: event.c:42
#define SD_SEND
Definition: winsock.h:55
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
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

◆ Exit()

static void Exit ( void  )
static

Definition at line 1331 of file sock.c.

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:58
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
int ret
#define err(...)
#define ok(value,...)
Definition: atltest.h:57
static DWORD tls
Definition: sock.c:230

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(), AcpiEvExecuteOrphanRegMethod(), AcpiExCreateMethod(), AcpiExInsertIntoField(), AcpiExReadDataFromField(), AcpiExResolveMultiple(), AcpiHwClearAcpiStatus(), AcpiHwRegisterWrite(), AcpiInstallSciHandler(), AcpiNsCheckReturnValue(), AcpiRsConvertAmlToResource(), AcpiRsConvertResourceToAml(), AcpiTbInstallAndLoadTable(), AcpiUtAllocateOwnerId(), af_autofitter_load_glyph(), 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(), ClasspAccessAlignmentProperty(), ClasspDeviceGetBlockDeviceCharacteristicsVPDPage(), ClasspDeviceGetBlockLimitsVPDPage(), ClasspDeviceGetLBAStatus(), ClasspDeviceGetLBAStatusWorker(), ClasspDeviceGetLBProvisioningVPDPage(), ClasspDeviceLBProvisioningProperty(), ClasspDeviceSeekPenaltyProperty(), ClasspDeviceTrimProcess(), ClasspDeviceTrimProperty(), ClassReadWrite(), CmpCreateLinkNode(), CmpDoCreate(), CmpGetSymbolicLink(), CmpRemoveSubKey(), co_HOOK_CallHooks(), co_IntProcessKeyboardMessage(), co_MsqDispatchOneSentMessage(), CommonInstall(), CreateDIBitmap(), DefSetText(), DeviceProcessDsmTrimRequest(), FxInterrupt::Disconnect(), DispTdiQueryIpHwAddress(), DoAppSwitch(), DriverEvtDeviceAdd(), EngCreateWnd(), EnumHKCRKey(), EnumHKCRValue(), fnt_face_get_dll_font(), FNT_Face_Init(), fnt_font_load(), FNT_Load_Glyph(), FreeDeviceData(), 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(), GdiConvertEnhMetaFile(), GdiConvertMetaFilePict(), GdiCreateLocalEnhMetaFile(), GdiCreateLocalMetaFilePict(), 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(), HalpGetRootInterruptVector(), hash_insert(), hash_rehash(), Horizontal_Sweep_Drop(), IntCallWindowProcA(), IntCallWindowProcW(), LdrpCreateDllSection(), 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(), 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(), 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(), RtlGetNtProductType(), RtlpLookupDynamicFunctionEntry(), RtlVirtualUnwind(), SetDIBitsToDevice(), sfnt_load_face(), START_TEST(), StretchDIBits(), 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(), TestIrpHandler(), 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().

◆ fill_buffer()

static void fill_buffer ( char buf,
int  chunk_size,
int  n_chunks 
)
static

Definition at line 362 of file sock.c.

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
const GLubyte * c
Definition: glext.h:8905
#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

Referenced by client_start().

◆ flush_events()

static void flush_events ( SOCKET  s,
HANDLE  hEvent 
)
static

Definition at line 5630 of file sock.c.

5631 {
5632  WSANETWORKEVENTS netEvents;
5633  struct async_message *prev = NULL, *curr = messages_received;
5634  int ret;
5635  DWORD dwRet;
5636 
5638  {
5639  dwRet = WaitForSingleObject(hEvent, 100);
5640  if (dwRet == WAIT_OBJECT_0)
5641  {
5642  ret = WSAEnumNetworkEvents(s, hEvent, &netEvents);
5643  if (ret)
5644  ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5645  }
5646  }
5647  else
5648  {
5649  while (curr)
5650  {
5651  if (curr->socket == s)
5652  {
5653  if (prev) prev->next = curr->next;
5654  else messages_received = curr->next;
5655 
5656  HeapFree(GetProcessHeap(), 0, curr);
5657 
5658  if (prev) curr = prev->next;
5659  else curr = messages_received;
5660  }
5661  else
5662  {
5663  prev = curr;
5664  curr = curr->next;
5665  }
5666  }
5667  }
5668 }
struct async_message * next
Definition: sock.c:5501
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static struct async_message * messages_received
Definition: sock.c:5504
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define GetProcessHeap()
Definition: compat.h:736
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
int ret
GLdouble s
Definition: gl.h:2039
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by ok_event_sequence(), and test_events().

◆ get_event_details()

static void get_event_details ( int  event,
int bit,
char name 
)
static

Definition at line 5533 of file sock.c.

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

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

◆ gethostname()

int WINAPI gethostname ( char name,
int  namelen 
)

◆ inet_ntoa_thread_proc()

static DWORD WINAPI inet_ntoa_thread_proc ( void param)
static

Definition at line 10543 of file sock.c.

10544 {
10545  ULONG addr;
10546  const char *str;
10547  HANDLE *event = param;
10548 
10549  addr = inet_addr("4.3.2.1");
10550  ok(addr == htonl(0x04030201), "expected 0x04030201, got %08x\n", addr);
10551  str = inet_ntoa(*(struct in_addr *)&addr);
10552  ok(!strcmp(str, "4.3.2.1"), "expected 4.3.2.1, got %s\n", str);
10553 
10554  SetEvent(event[0]);
10555  WaitForSingleObject(event[1], 3000);
10556 
10557  return 0;
10558 }
#define inet_addr(cp)
Definition: inet.h:98
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define htonl(x)
Definition: module.h:212
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const WCHAR * str
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: tcpip.h:125
GLfloat param
Definition: glext.h:5796
GLenum const GLvoid * addr
Definition: glext.h:9621
struct _cl_event * event
Definition: glext.h:7739
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by test_inet_ntoa().

◆ Init()

static void Init ( void  )
static

Definition at line 1288 of file sock.c.

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 }
#define MAKEWORD(a, b)
Definition: typedefs.h:248
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:753
static DWORD tls
Definition: sock.c:230

Referenced by START_TEST().

◆ int()

static int ( WINAPI pgetaddrinfo)
static

◆ io_completion()

static void WINAPI io_completion ( DWORD  error,
DWORD  transferred,
WSAOVERLAPPED overlapped,
DWORD  flags 
)
static

Definition at line 6742 of file sock.c.

6743 {
6745 }
static int completion_called
Definition: sock.c:6740

Referenced by test_WSARecv().

◆ iocp_async_closesocket()

static void iocp_async_closesocket ( SOCKET  src)
static

Definition at line 11144 of file sock.c.

11145 {
11146  HANDLE port;
11147  WSAOVERLAPPED *ovl_iocp;
11148  int ret;
11149  DWORD bytes;
11150  ULONG_PTR key;
11151  HWND hwnd;
11152  MSG msg;
11153 
11154  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11155  0, 0, 0, 0, NULL, NULL, 0, NULL);
11156  ok(hwnd != 0, "CreateWindowEx failed\n");
11157 
11159  ok(!ret, "got %d\n", ret);
11160 
11161  Sleep(100);
11162  memset(&msg, 0, sizeof(msg));
11164  ok(ret, "got %d\n", ret);
11165  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11166  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11167  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11168  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11169 
11170  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11171  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11172 
11173  Sleep(100);
11175  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11176 
11177  bytes = 0xdeadbeef;
11178  key = 0xdeadbeef;
11179  ovl_iocp = (void *)0xdeadbeef;
11180  SetLastError(0xdeadbeef);
11181  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11182  ok(!ret, "got %d\n", ret);
11183  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11184  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11185  ok(key == 0xdeadbeef, "got key %lu\n", key);
11186  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11187 
11188  Sleep(100);
11190  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11191 
11192  closesocket(src);
11193 
11194  Sleep(100);
11195  memset(&msg, 0, sizeof(msg));
11197  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11198 
11199  bytes = 0xdeadbeef;
11200  key = 0xdeadbeef;
11201  ovl_iocp = (void *)0xdeadbeef;
11202  SetLastError(0xdeadbeef);
11203  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11204  ok(!ret, "got %d\n", ret);
11205  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11206  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11207  ok(key == 0xdeadbeef, "got key %lu\n", key);
11208  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11209 
11210  CloseHandle(port);
11211 
11213 }
#define CloseHandle
Definition: compat.h:739
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#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:131
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define closesocket
Definition: ncftp.h:477
#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
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FD_WRITE
Definition: winsock.h:406
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
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:5506
#define FD_CLOSE
Definition: winsock.h:410
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
#define WAIT_TIMEOUT
Definition: dderror.h:14
int ret
HKEY key
Definition: reg.c:28
GLenum src
Definition: glext.h:6340
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:65
#define ok(value,...)
Definition: atltest.h:57
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#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:1186
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
Definition: copy.c:22

Referenced by test_iocp().

◆ iocp_async_read()

static void iocp_async_read ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 10933 of file sock.c.

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

Referenced by test_iocp().

◆ iocp_async_read_closesocket()

static void iocp_async_read_closesocket ( SOCKET  src,
int  how_to_close 
)
static

Definition at line 11003 of file sock.c.

11004 {
11005  HANDLE port;
11006  WSAOVERLAPPED ovl, *ovl_iocp;
11007  WSABUF buf;
11008  int ret;
11009  char data[512];
11010  DWORD flags, bytes;
11011  ULONG_PTR key;
11012  HWND hwnd;
11013  MSG msg;
11014 
11015  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11016  0, 0, 0, 0, NULL, NULL, 0, NULL);
11017  ok(hwnd != 0, "CreateWindowEx failed\n");
11018 
11020  ok(!ret, "got %d\n", ret);
11021 
11022  Sleep(100);
11023  memset(&msg, 0, sizeof(msg));
11025  ok(ret, "got %d\n", ret);
11026  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11027  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11028  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11029  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11030 
11031  memset(data, 0, sizeof(data));
11032  memset(&ovl, 0, sizeof(ovl));
11033 
11034  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11035  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11036 
11037  Sleep(100);
11039  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11040 
11041  buf.len = sizeof(data);
11042  buf.buf = data;
11043  bytes = 0xdeadbeef;
11044  flags = 0;
11045  SetLastError(0xdeadbeef);
11046  ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL);
11047  ok(ret == SOCKET_ERROR, "got %d\n", ret);
11048  ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
11049  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11050 
11051  Sleep(100);
11053  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11054 
11055  bytes = 0xdeadbeef;
11056  key = 0xdeadbeef;
11057  ovl_iocp = (void *)0xdeadbeef;
11058  SetLastError(0xdeadbeef);
11059  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11060  ok(!ret, "got %d\n", ret);
11061  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11062  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11063  ok(key == 0xdeadbeef, "got key %#lx\n", key);
11064  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11065 
11066  Sleep(100);
11068  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11069 
11070  switch (how_to_close)
11071  {
11072  case 0:
11073  closesocket(src);
11074  break;
11075  case 1:
11077  break;
11078  case 2:
11079  pNtClose((HANDLE)src);
11080  break;
11081  default:
11082  ok(0, "wrong value %d\n", how_to_close);
11083  break;
11084  }
11085 
11086  Sleep(200);
11087  memset(&msg, 0, sizeof(msg));
11089  switch (how_to_close)
11090  {
11091  case 0:
11092  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11093  break;
11094  case 1:
11095  case 2:
11096 todo_wine
11097 {
11098  ok(ret, "got %d\n", ret);
11099  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11100  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11101  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11102  ok(msg.lParam == 0x20, "got %08lx\n", msg.lParam);
11103 }
11104  break;
11105  default:
11106  ok(0, "wrong value %d\n", how_to_close);
11107  break;
11108  }
11109 
11110  bytes = 0xdeadbeef;
11111  key = 0xdeadbeef;
11112  ovl_iocp = NULL;
11113  SetLastError(0xdeadbeef);
11114  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11115  ok(!ret, "got %d\n", ret);
11116 todo_wine
11118  ok(!bytes, "got bytes %u\n", bytes);
11119  ok(key == 0x12345678, "got key %#lx\n", key);
11120  ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp);
11121  if (ovl_iocp)
11122  {
11123  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11124 todo_wine
11125  ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11126  }
11127 
11128  bytes = 0xdeadbeef;
11129  key = 0xdeadbeef;
11130  ovl_iocp = (void *)0xdeadbeef;
11131  SetLastError(0xdeadbeef);
11132  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11133  ok(!ret, "got %d\n", ret);
11134  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11135  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11136  ok(key == 0xdeadbeef, "got key %#lx\n", key);
11137  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11138 
11139  CloseHandle(port);
11140 
11142 }
#define ERROR_NETNAME_DELETED
Definition: winerror.h:156
#define SOCKET_ERROR
Definition: winsock.h:333
#define CloseHandle
Definition: compat.h:739
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define ERROR_CONNECTION_ABORTED
Definition: winerror.h:739
#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:131
#define todo_wine
Definition: custom.c:79
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define closesocket
Definition: ncftp.h:477
#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
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FD_WRITE
Definition: winsock.h:406
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
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:5506
#define FD_CLOSE
Definition: winsock.h:410
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
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:709
int ret
HKEY key
Definition: reg.c:28
GLenum src
Definition: glext.h:6340
HANDLE WINAPI CreateIoCompletionPort(IN HANDLE FileHandle, IN HANDLE ExistingCompletionPort, IN ULONG_PTR CompletionKey, IN DWORD NumberOfConcurrentThreads)
Definition: iocompl.c:65
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 ok(value,...)
Definition: atltest.h:57
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:551
#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:1186
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
Definition: copy.c:22

Referenced by test_iocp().

◆ iocp_async_read_thread()

static void iocp_async_read_thread ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 11384 of file sock.c.

11385 {
11386  struct wsa_async_select_info select_info;
11387  struct wsa_recv_info recv_info;
11388  HANDLE port, thread;
11389  WSAOVERLAPPED *ovl_iocp;
11390  int ret;
11391  char data[512];
11392  DWORD bytes, tid;
11393  ULONG_PTR key;
11394  HWND hwnd;
11395  MSG msg;
11396 
11397  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11398  0, 0, 0, 0, NULL, NULL, 0, NULL);
11399  ok(hwnd != 0, "CreateWindowEx failed\n");
11400 
11401  select_info.sock = src;
11402  select_info.hwnd = hwnd;
11403  thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11404  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11405  ret = WaitForSingleObject(thread, 10000);
11406  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11407 
11408  Sleep(100);
11409  memset(&msg, 0, sizeof(msg));
11411  ok(ret, "got %d\n", ret);
11412  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11413  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11414  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11415  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11416 
11417  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11418  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11419 
11420  Sleep(100);
11422  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11423 
11424  memset(data, 0, sizeof(data));
11425  memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11426  recv_info.sock = src;
11427  recv_info.wsa_buf.len = sizeof(data);
11428  recv_info.wsa_buf.buf = data;
11429  thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11430  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11431  ret = WaitForSingleObject(thread, 10000);
11432  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11433 
11434  Sleep(100);
11436  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11437 
11438  bytes = 0xdeadbeef;
11439  key = 0xdeadbeef;
11440  ovl_iocp = (void *)0xdeadbeef;
11441  SetLastError(0xdeadbeef);
11442  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11443  ok(!ret, "got %d\n", ret);
11444  ok(GetLastError() == WAIT_TIMEOUT || broken(GetLastError() == ERROR_OPERATION_ABORTED) /* XP */, "got %u\n", GetLastError());
11445  if (GetLastError() == WAIT_TIMEOUT)
11446  {
11447  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11448  ok(key == 0xdeadbeef, "got key %lu\n", key);
11449  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11450  }
11451  else /* document XP behaviour */
11452  {
11453  ok(bytes == 0, "got bytes %u\n", bytes);
11454  ok(key == 0x12345678, "got key %#lx\n", key);
11455  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11456  if (ovl_iocp)
11457  {
11458  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11459  ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11460  }
11461  }
11462 
11463  Sleep(100);
11464  memset(&msg, 0, sizeof(msg));
11466  ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11467  if (ret) /* document XP behaviour */
11468  {
11469  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11470  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11471  ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11472  }
11473 
11474  ret = send(dst, "Hello World!", 12, 0);
11475  ok(ret == 12, "send returned %d\n", ret);
11476 
11477  Sleep(100);
11478  memset(&msg, 0, sizeof(msg));
11480  ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11481  if (ret) /* document XP behaviour */
11482  {
11483  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11484  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11485  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11486  ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11487  }
11488 
11489  bytes = 0xdeadbeef;
11490  key = 0xdeadbeef;
11491  ovl_iocp = (void *)0xdeadbeef;
11492  SetLastError(0xdeadbeef);
11493  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11494  ok(ret || broken(GetLastError() == WAIT_TIMEOUT) /* XP */, "got %u\n", GetLastError());
11495  if (ret)
11496  {
11497  ok(bytes == 12, "got bytes %u\n", bytes);
11498  ok(key == 0x12345678, "got key %#lx\n", key);
11499  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11500  if (ovl_iocp)
11501  {
11502  ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh);
11503  ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal);
11504  ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data);
11505  }
11506  }
11507  else /* document XP behaviour */
11508  {
11509  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11510  ok(key == 0xdeadbeef, "got key %lu\n", key);
11511  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11512  }
11513 
11514  CloseHandle(port);
11515 
11517 }
#define CloseHandle
Definition: compat.h:739
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
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:131
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#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:65
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
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:137
#define WM_SOCKET
Definition: sock.c:5506
#define WAIT_OBJECT_0
Definition: winbase.h:406
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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
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:28
GLenum src
Definition: glext.h:6340
#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:65
static DWORD WINAPI wsa_recv_thread(void *param)
Definition: sock.c:11239
#define ok(value,...)
Definition: atltest.h:57
GLenum GLenum dst
Definition: glext.h:6340
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
static DWORD WINAPI wsa_async_select_thread(void *param)
Definition: sock.c:11221
#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:1186
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
static TfClientId tid
Definition: copy.c:22

Referenced by test_iocp().

◆ iocp_async_read_thread_closesocket()

static void iocp_async_read_thread_closesocket ( SOCKET  src)
static

Definition at line 11256 of file sock.c.

11257 {
11258  struct wsa_async_select_info select_info;
11259  struct wsa_recv_info recv_info;
11260  HANDLE port, thread;
11261  WSAOVERLAPPED *ovl_iocp;
11262  int ret;
11263  char data[512];
11264  DWORD bytes, tid;
11265  ULONG_PTR key;
11266  HWND hwnd;
11267  MSG msg;
11268 
11269  hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11270  0, 0, 0, 0, NULL, NULL, 0, NULL);
11271  ok(hwnd != 0, "CreateWindowEx failed\n");
11272 
11273  select_info.sock = src;
11274  select_info.hwnd = hwnd;
11275  thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11276  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11277  ret = WaitForSingleObject(thread, 10000);
11278  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11279 
11280  Sleep(100);
11281  memset(&msg, 0, sizeof(msg));
11283  ok(ret, "got %d\n", ret);
11284  ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11285  ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11286  ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11287  ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11288 
11289  port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11290  ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11291 
11292  Sleep(100);
11294  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11295 
11296  memset(data, 0, sizeof(data));
11297  memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11298  recv_info.sock = src;
11299  recv_info.wsa_buf.len = sizeof(data);
11300  recv_info.wsa_buf.buf = data;
11301  thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11302  ok(thread != 0, "CreateThread error %u\n", GetLastError());
11303  ret = WaitForSingleObject(thread, 10000);
11304  ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11305 
11306  Sleep(100);
11308  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11309 
11310  bytes = 0xdeadbeef;
11311  key = 0xdeadbeef;
11312  ovl_iocp = (void *)0xdeadbeef;
11313  SetLastError(0xdeadbeef);
11314  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11315  ok(!ret, "got %d\n", ret);
11317  "got %u\n", GetLastError());
11318  if (GetLastError() == WAIT_TIMEOUT)
11319  {
11320  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11321  ok(key == 0xdeadbeef, "got key %lx\n", key);
11322  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11323  }
11324  else /* document XP behaviour */
11325  {
11326  ok(!bytes, "got bytes %u\n", bytes);
11327  ok(key == 0x12345678, "got key %#lx\n", key);
11328  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11329  if (ovl_iocp)
11330  {
11331  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11332  ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11333  }
11334 
11335  closesocket(src);
11336  goto xp_is_broken;
11337  }
11338 
11339  Sleep(100);
11341  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11342 
11343  closesocket(src);
11344 
11345  Sleep(100);
11347  ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11348 
11349  bytes = 0xdeadbeef;
11350  key = 0xdeadbeef;
11351  ovl_iocp = NULL;
11352  SetLastError(0xdeadbeef);
11353  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11354  ok(!ret, "got %d\n", ret);
11355 todo_wine
11357  ok(!bytes, "got bytes %u\n", bytes);
11358  ok(key == 0x12345678, "got key %#lx\n", key);
11359  ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11360  if (ovl_iocp)
11361  {
11362  ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11363 todo_wine
11364  ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11365  }
11366 
11367 xp_is_broken:
11368  bytes = 0xdeadbeef;
11369  key = 0xdeadbeef;
11370  ovl_iocp = (void *)0xdeadbeef;
11371  SetLastError(0xdeadbeef);
11372  ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11373  ok(!ret, "got %d\n", ret);
11374  ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11375  ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11376  ok(key == 0xdeadbeef, "got key %lu\n", key);
11377  ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11378 
11379  CloseHandle(port);
11380 
11382 }
#define ERROR_NETNAME_DELETED
Definition: winerror.h:156
#define CloseHandle
Definition: compat.h:739
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#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:131
#define todo_wine
Definition: custom.c:79
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define closesocket
Definition: ncftp.h:477
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#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:65
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
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:137
#define WM_SOCKET
Definition: sock.c:5506
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:752
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:709
int ret
HKEY key
Definition: reg.c:28
GLenum src
Definition: glext.h:6340
#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:65
static DWORD WINAPI wsa_recv_thread(void *param)
Definition: sock.c:11239
#define ok(value,...)
Definition: atltest.h:57
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:551
static DWORD WINAPI wsa_async_select_thread(void *param)
Definition: sock.c:11221
#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:1186
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
static TfClientId tid
Definition: copy.c:22

Referenced by test_iocp().

◆ match_event_sequence()

static int match_event_sequence ( SOCKET  s,
WSANETWORKEVENTS netEvents,
const LPARAM seq 
)
static

Definition at line 5670 of file sock.c.

5671 {
5672  int event, index, error, events;
5673  struct async_message *curr;
5674 
5675  if (netEvents)
5676  {
5677  events = netEvents->lNetworkEvents;
5678  while (*seq)
5679  {
5680  event = WSAGETSELECTEVENT(*seq);
5681  error = WSAGETSELECTERROR(*seq);
5683 
5684  if (!(events & event) && index != -1)
5685  return 0;
5686  if (events & event && index != -1)
5687  {
5688  if (netEvents->iErrorCode[index] != error)
5689  return 0;
5690  }
5691  events &= ~event;
5692  seq++;
5693  }
5694  if (events)
5695  return 0;
5696  }
5697  else
5698  {
5699  curr = messages_received;
5700  while (curr)
5701  {
5702  if (curr->socket == s)
5703  {
5704  if (!*seq) return 0;
5705  if (*seq != curr->lparam) return 0;
5706  seq++;
5707  }
5708  curr = curr->next;
5709  }
5710  if (*seq)
5711  return 0;
5712  }
5713  return 1;
5714 }
#define error(str)
Definition: mkdosfs.c:1605
struct async_message * next
Definition: sock.c:5501
SOCKET socket
Definition: sock.c:5499
static struct async_message * messages_received
Definition: sock.c:5504
LPARAM lparam
Definition: sock.c:5500
GLuint index
Definition: glext.h:6031
#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
#define NULL
Definition: types.h:112
HANDLE events[2]
Definition: event.c:4
static void get_event_details(int event, int *bit, char *name)
Definition: sock.c:5533

Referenced by ok_event_sequence().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtSetInformationFile)
static

◆ ok_event_sequence()

static void ok_event_sequence ( SOCKET  s,
HANDLE  hEvent,
const LPARAM seq,
const LPARAM **  broken_seqs,
int  completelyBroken 
)
static

Definition at line 5717 of file sock.c.

5718 {
5719  MSG msg;
5720  WSANETWORKEVENTS events, *netEvents = NULL;
5721  int ret;
5722  DWORD dwRet;
5723 
5725  {
5726  netEvents = &events;
5727 
5728  dwRet = WaitForSingleObject(hEvent, 200);
5729  if (dwRet == WAIT_OBJECT_0)
5730  {
5731  ret = WSAEnumNetworkEvents(s, hEvent, netEvents);
5732  if (ret)
5733  {
5734  winetest_ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5735  return;
5736  }
5737  }
5738  else
5739  memset(netEvents, 0, sizeof(*netEvents));
5740  }
5741  else
5742  {
5743  Sleep(200);
5744  /* Run the message loop a little */
5745  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
5746  {
5748  }
5749  }
5750 
5751  if (match_event_sequence(s, netEvents, seq))
5752  {
5753  winetest_ok(1, "Sequence matches expected: %s\n", dbgstr_event_seq(seq));
5754  flush_events(s, hEvent);
5755  return;
5756  }
5757 
5758  if (broken_seqs)
5759  {
5760  for (; *broken_seqs; broken_seqs++)
5761  {
5762  if (match_event_sequence(s, netEvents, *broken_seqs))
5763  {
5764  winetest_ok(broken(1), "Sequence matches broken: %s, expected %s\n", dbgstr_event_seq_result(s, netEvents), dbgstr_event_seq(seq));
5765  flush_events(s, hEvent);
5766  return;
5767  }
5768  }
5769  }
5770 
5771  winetest_ok(broken(completelyBroken), "Expected event sequence %s, got %s\n", dbgstr_event_seq(seq),
5772  dbgstr_event_seq_result(s, netEvents));
5773  flush_events(s, hEvent);
5774 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
static const char * dbgstr_event_seq(const LPARAM *seq)
Definition: sock.c:5567
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
static HANDLE hEvent
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:406
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
unsigned long DWORD
Definition: ntddk_ex.h:95
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:5586
GLdouble s
Definition: gl.h:2039
#define broken(x)
Definition: _sntprintf.h:21
static void flush_events(SOCKET s, HANDLE hEvent)
Definition: sock.c:5630
#define NULL
Definition: types.h:112
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:5670
#define PM_REMOVE
Definition: winuser.h:1186
#define memset(x, y, z)
Definition: compat.h:39

◆ oob_client()

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 }
test_params * general
Definition: sock.c:149
static void check_so_opentype(void)
Definition: sock.c:437
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define TRUE
Definition: types.h:120
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:356
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:459
#define trace
Definition: atltest.h:70
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
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
#define ok(value,...)
Definition: atltest.h:57
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:1240
Definition: mem.c:156
int chunk_size
Definition: sock.c:133
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

◆ oob_server()

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 SIOCATMARK
Definition: winsock.h:253
unsigned long u_long
Definition: linux.h:269
#define inet_addr(cp)
Definition: inet.h:98
#define TRUE
Definition: types.h:120
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:356
#define todo_wine
Definition: custom.c:79
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define ioctlsocket
Definition: ncftp.h:481
#define closesocket
Definition: ncftp.h:477
#define SOMAXCONN
Definition: winsock.h:399
#define FALSE
Definition: types.h:117
static void server_start(server_params *par)
Definition: sock.c:522
test_params * general
Definition: sock.c:141
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
#define trace
Definition: atltest.h:70
#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
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
#define ok(value,...)
Definition: atltest.h:57
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:1240
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

◆ PCSTR()

static PCSTR ( WINAPI pInetNtop)
static

◆ PCWSTR()

static PCWSTR ( WINAPI pInetNtopW)
static

◆ poll_isset()

static BOOL poll_isset ( WSAPOLLFD *  fds,
int  max,
SOCKET  s,
int  rev 
)
static

Definition at line 7116 of file sock.c.

7117 {
7118  int k;
7119  for (k = 0; k < max; k++)
7120  if (fds[k].fd == s && (fds[k].revents == rev)) return TRUE;
7121  return FALSE;
7122 }
#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

◆ read_zero_bytes()

static void read_zero_bytes ( SOCKET  s)
static

Definition at line 385 of file sock.c.

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 }
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble s
Definition: gl.h:2039
#define ok(value,...)
Definition: atltest.h:57
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23

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

◆ recv_thread()

static DWORD WINAPI recv_thread ( LPVOID  arg)
static

Definition at line 6722 of file sock.c.

6723 {
6724  SOCKET sock = *(SOCKET *)arg;
6725  char buffer[32];
6726  WSABUF wsa;
6727  WSAOVERLAPPED ov;
6728  DWORD flags = 0;
6729 
6730  wsa.buf = buffer;
6731  wsa.len = sizeof(buffer);
6732  ov.hEvent = WSACreateEvent();
6733  WSARecv(sock, &wsa, 1, NULL, &flags, &ov, NULL);
6734 
6735  WaitForSingleObject(ov.hEvent, 1000);
6736  WSACloseEvent(ov.hEvent);
6737  return 0;
6738 }
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WSAAPI WSACloseEvent(IN WSAEVENT hEvent)
Definition: event.c:23
ULONG len
Definition: ws2def.h:519
unsigned long DWORD
Definition: ntddk_ex.h:95
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 NULL
Definition: types.h:112
#define WSAOVERLAPPED
Definition: winsock2.h:587
Definition: tcpcore.h:1455
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by test_WSARecv().

◆ select_server()

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 inet_addr(cp)
Definition: inet.h:98
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:356
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define closesocket
Definition: ncftp.h:477
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
#define SOMAXCONN
Definition: winsock.h:399
#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
test_params * general
Definition: sock.c:141
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
#define MAX_CLIENTS
Definition: sock.c:46
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
#define trace
Definition: atltest.h:70
#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
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int n_clients
Definition: sock.c:135
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
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:1240
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

◆ SelectCloseThread()

static DWORD WINAPI SelectCloseThread ( void param)
static

Definition at line 3650 of file sock.c.

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:790
#define closesocket
Definition: ncftp.h:477
GLfloat param
Definition: glext.h:5796
GLdouble s
Definition: gl.h:2039
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by test_select(), and test_WSAPoll().

◆ SelectReadThread()

static DWORD WINAPI SelectReadThread ( void param)
static

Definition at line 3623 of file sock.c.

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,