ReactOS 0.4.16-dev-746-g329a414
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 *p_inet_ntop)(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 9030 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 3779 of file sock.c.

◆ FD_ZERO_ALL

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

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

◆ make_keepalive

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

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

◆ NUM_THREADS

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

Definition at line 54 of file sock.c.

◆ NUM_UDP_PEERS

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

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

◆ POLL_CLEAR

#define POLL_CLEAR ( )    ix = 0

Definition at line 7313 of file sock.c.

◆ POLL_ISSET

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

Definition at line 7315 of file sock.c.

◆ POLL_SET

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

Definition at line 7314 of file sock.c.

◆ SERVERIP

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

Definition at line 57 of file sock.c.

◆ SERVERPORT

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

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

◆ SOCKTIMEOUT2

#define SOCKTIMEOUT2   997000 /* 997 seconds */

Definition at line 1406 of file sock.c.

◆ STD_STREAM_SOCKET

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

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

◆ WM_SOCKET

#define WM_SOCKET   (WM_USER+100)

Definition at line 5697 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);
#define msg(x)
Definition: auth_time.c:54
UINT op
Definition: effect.c:236
#define err(...)
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112

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

4161{
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);
GLuint address
Definition: glext.h:9393
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
#define closesocket
Definition: ncftp.h:477
static HANDLE server_ready
Definition: sock.c:232
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define INVALID_SOCKET
Definition: winsock.h:332
UINT_PTR SOCKET
Definition: winsock.h:47

◆ 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 4174 of file sock.c.

4179{

◆ check_so_opentype()

static void check_so_opentype ( void  )
static

Definition at line 436 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 );
#define ok(value,...)
Definition: atltest.h:57
#define SO_OPENTYPE
Definition: ws2_32.h:40
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 SOL_SOCKET
Definition: winsock.h:398

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

◆ client_start()

static void client_start ( client_params par)
static

Definition at line 566 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 */
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
Definition: addrconv.c:71
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
#define AF_INET
Definition: tcpip.h:117
#define INFINITE
Definition: serial.h:102
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define htons(x)
Definition: module.h:215
#define min(a, b)
Definition: monoChain.cc:55
#define MAX_CLIENTS
Definition: sock.c:46
static HANDLE client_ready[MAX_CLIENTS]
Definition: sock.c:233
static void fill_buffer(char *buf, int chunk_size, int n_chunks)
Definition: sock.c:361
static int client_id
Definition: sock.c:234
static DWORD tls
Definition: sock.c:229
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
DWORD sock_flags
Definition: sock.c:149
test_params * general
Definition: sock.c:148
Definition: mem.c:349
int sock_type
Definition: sock.c:128
const char * inet_addr
Definition: sock.c:130
int sock_prot
Definition: sock.c:129
int n_chunks
Definition: sock.c:133
short inet_port
Definition: sock.c:131
int n_clients
Definition: sock.c:134
int chunk_size
Definition: sock.c:132
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
#define LPTR
Definition: winbase.h:407

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

◆ client_stop()

static void client_stop ( void  )
static

Definition at line 593 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);
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define wsa_ok(op, cond, msg)
Definition: sock.c:60

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 444 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);
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define b
Definition: ke_i.h:79

◆ compare_addrinfow()

static void compare_addrinfow ( ADDRINFOW a,
ADDRINFOW b 
)
static

Definition at line 472 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);
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
#define wine_dbgstr_w
Definition: kernel32.h:34

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 9032 of file sock.c.

9035{
9036 char buf1[256], buf2[256];
9037 BOOL success;
9038 int i = 0;
9039
9041 while (1)
9042 {
9043 DWORD n1 = 0, n2 = 0;
9044
9045 success = ReadFile(handle, buf1, sizeof(buf1), &n1, NULL);
9046 ok_(file,line)(success, "Failed to read from file.\n");
9047 if (success && n1 == 0)
9048 break;
9049 else if(!success)
9050 return;
9051 n2 = recv(sock, buf2, n1, 0);
9052 ok_(file,line)(n1 == n2, "Block %d size mismatch (%d != %d)\n", i, n1, n2);
9053 ok_(file,line)(memcmp(buf1, buf2, n2) == 0, "Block %d failed\n", i);
9054 i++;
#define ok_(x1, x2)
Definition: atltest.h:61
#define FILE_BEGIN
Definition: compat.h:761
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLintptr offset
Definition: glext.h:5920
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 n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
Definition: fci.c:127
Definition: parser.c:49
Definition: tcpcore.h:1455
#define success(from, fromstr, to, tostr)

◆ create_async_message_window()

static HWND create_async_message_window ( void  )
static

Definition at line 9697 of file sock.c.

9700{
9701 static const char class_name[] = "ws2_32 async message window class";
9702
9703 WNDCLASSEXA wndclass;
9704 HWND hWnd;
9705
9706 wndclass.cbSize = sizeof(wndclass);
9707 wndclass.style = CS_HREDRAW | CS_VREDRAW;
9708 wndclass.lpfnWndProc = DefWindowProcA;
9709 wndclass.cbClsExtra = 0;
9710 wndclass.cbWndExtra = 0;
9711 wndclass.hInstance = GetModuleHandleA(NULL);
9714 wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
9715 wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
9716 wndclass.lpszClassName = class_name;
9717 wndclass.lpszMenuName = NULL;
9718
9719 RegisterClassExA(&wndclass);
9720
9721 hWnd = CreateWindowA(class_name, "ws2_32 async message window", WS_OVERLAPPEDWINDOW,
9722 0, 0, 500, 500, NULL, NULL, GetModuleHandleA(NULL), NULL);
9723 if (!hWnd)
9724 {
9725 ok(0, "failed to create window: %u\n", GetLastError());
9726 return NULL;
9727 }
9728
HWND hWnd
Definition: settings.c:17
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
int cbClsExtra
Definition: winuser.h:3207
HINSTANCE hInstance
Definition: winuser.h:3209
HCURSOR hCursor
Definition: winuser.h:3211
LPCSTR lpszMenuName
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3215
UINT style
Definition: winuser.h:3205
int cbWndExtra
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3204
WNDPROC lpfnWndProc
Definition: winuser.h:3206
LPCSTR lpszClassName
Definition: winuser.h:3214
HICON hIcon
Definition: winuser.h:3210
HBRUSH hbrBackground
Definition: winuser.h:3212
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CS_VREDRAW
Definition: winuser.h:658
#define COLOR_WINDOW
Definition: winuser.h:921
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4318
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2146
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2176
const char * LPCSTR
Definition: xmlstorage.h:183

◆ dbgstr_event_seq()

static const char * dbgstr_event_seq ( const LPARAM seq)
static

Definition at line 5758 of file sock.c.

5761{
5762 static char message[1024];
5763 char name[12];
5764 int len = 1;
5765
5766 message[0] = '[';
5767 message[1] = 0;
5768 while (*seq)
5769 {
5771 len += sprintf(message + len, "%s(%d) ", name, WSAGETSELECTERROR(*seq));
5772 seq++;
5773 }
5774 if (len > 1) len--;
5775 strcpy( message + len, "]" );
#define sprintf(buf, format,...)
Definition: sprintf.c:55
strcpy
Definition: string.h:131
static void get_event_details(int event, int *bit, char *name)
Definition: sock.c:5724
Definition: tftpd.h:60
Definition: name.c:39
#define WSAGETSELECTERROR(l)
Definition: winsock.h:482
#define WSAGETSELECTEVENT(l)
Definition: winsock.h:481

Referenced by ok_event_sequence().

◆ dbgstr_event_seq_result()

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

Definition at line 5777 of file sock.c.

5780{
5781 static char message[1024];
5782 struct async_message *curr = messages_received;
5783 int index, error, bit = 0;
5784 char name[12];
5785 int len = 1;
5786
5787 message[0] = '[';
5788 message[1] = 0;
5789 while (1)
5790 {
5791 if (netEvents)
5792 {
5793 if (bit >= FD_MAX_EVENTS) break;
5794 if ( !(netEvents->lNetworkEvents & (1 << bit)) )
5795 {
5796 bit++;
5797 continue;
5798 }
5799 get_event_details(1 << bit, &index, name);
5800 error = netEvents->iErrorCode[index];
5801 bit++;
5802 }
5803 else
5804 {
5805 if (!curr) break;
5806 if (curr->socket != s)
5807 {
5808 curr = curr->next;
5809 continue;
5810 }
5813 curr = curr->next;
5814 }
5815
5816 len += sprintf(message + len, "%s(%d) ", name, error);
5817 }
5818 if (len > 1) len--;
5819 strcpy( message + len, "]" );
#define index(s, c)
Definition: various.h:29
GLdouble s
Definition: gl.h:2039
GLuint index
Definition: glext.h:6031
#define error(str)
Definition: mkdosfs.c:1605
static struct async_message * messages_received
Definition: sock.c:5695
int iErrorCode[FD_MAX_EVENTS]
Definition: winsock2.h:644
SOCKET socket
Definition: sock.c:5690
LPARAM lparam
Definition: sock.c:5691
struct async_message * next
Definition: sock.c:5692
#define FD_MAX_EVENTS
Definition: winsock2.h:313

Referenced by ok_event_sequence().

◆ do_bind()

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

Definition at line 507 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 );
#define trace
Definition: atltest.h:70
GLenum const GLvoid * addr
Definition: glext.h:9621
#define BIND_TRIES
Definition: sock.c:49
#define BIND_SLEEP
Definition: sock.c:48
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define WSAEADDRINUSE
Definition: winerror.h:1961

Referenced by server_start().

◆ do_getservbyname()

static DWORD WINAPI do_getservbyname ( void param)
static

Definition at line 2347 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
static const CHAR s_name[]
Definition: ShowWindow.c:19
#define broken(x)
Definition: atltest.h:178
#define WAIT_TIMEOUT
Definition: dderror.h:14
USHORT port
Definition: uri.c:228
PSERVENT WSAAPI getservbyname(IN const char FAR *name, IN const char FAR *proto)
Definition: getxbyxx.c:500
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
#define ntohs(x)
Definition: module.h:210
#define NUM_QUERIES
Definition: sock.c:55
#define TEST_TIMEOUT
Definition: sock.c:50
short s_port
Definition: winsock.h:165
char * s_proto
Definition: winsock.h:166

◆ do_synchronous_recv()

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

Definition at line 406 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;
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
static UINT UINT last
Definition: font.c:45

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 419 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;
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
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 393 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;
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23

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 1362 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++)
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:587
#define test
Definition: rosglue.h:37
static DWORD thread_id[1+MAX_CLIENTS]
Definition: sock.c:231
static HANDLE thread[1+MAX_CLIENTS]
Definition: sock.c:230
static void StartClients(LPTHREAD_START_ROUTINE routine, test_params *general, client_params *par)
Definition: sock.c:1347
static void StartServer(LPTHREAD_START_ROUTINE routine, test_params *general, server_params *par)
Definition: sock.c:1339
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 WAIT_OBJECT_0
Definition: winbase.h:432

◆ drain_socket_thread()

static DWORD WINAPI drain_socket_thread ( LPVOID  arg)
static

Definition at line 5521 of file sock.c.

5524{
5525 char buffer[1024];
5526 SOCKET sock = *(SOCKET*)arg;
5527 int ret;
5528
5529 while ((ret = recv(sock, buffer, sizeof(buffer), 0)) != 0)
5530 {
5531 if (ret < 0)
5532 {
5534 {
5535 fd_set readset;
5536 FD_ZERO(&readset);
5537 FD_SET(sock, &readset);
5538 select(sock+1, &readset, NULL, NULL, NULL);
5539 while (drain_pause)
5540 Sleep(100);
5541 }
5542 else
5543 break;
5544 }
5545 }
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
GLuint buffer
Definition: glext.h:5915
static BOOL drain_pause
Definition: sock.c:5520
Definition: winsock.h:66
int ret
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89

Referenced by test_events().

◆ DWORD()

static DWORD ( WINAPI pGetAdaptersInfo)
static

◆ event_client()

static void WINAPI event_client ( client_params par)
static

Definition at line 1043 of file sock.c.

1045{
1046 test_params *gen = par->general;
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 );
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
1164out:
1165 WSACloseEvent ( event );
1166 trace ( "event_client (%x) exiting\n", id );
1167 client_stop ();
static TCHAR test_buffer[TEST_BUFFER_SIZE]
Definition: _tfileio.c:53
BOOL WSAAPI WSACloseEvent(IN WSAEVENT hEvent)
Definition: event.c:23
INT WSAAPI WSAEnumNetworkEvents(IN SOCKET s, IN WSAEVENT hEventObject, OUT LPWSANETWORKEVENTS lpNetworkEvents)
Definition: event.c:94
INT WSAAPI WSAEventSelect(IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
Definition: select.c:182
struct _cl_event * event
Definition: glext.h:7739
GLenum GLint GLuint mask
Definition: glext.h:6028
long LONG
Definition: pedump.c:60
static void client_stop(void)
Definition: sock.c:593
static void client_start(client_params *par)
Definition: sock.c:566
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
int buflen
Definition: sock.c:150
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define FD_CONNECT_BIT
Definition: winsock2.h:301
#define FD_CLOSE_BIT
Definition: winsock2.h:303
#define FD_READ_BIT
Definition: winsock2.h:293
WINSOCK_API_LINKAGE WSAEVENT WSAAPI WSACreateEvent(void)
Definition: event.c:42
#define FD_WRITE_BIT
Definition: winsock2.h:295
#define FD_READ
Definition: winsock.h:405
#define FD_WRITE
Definition: winsock.h:406
#define FD_CLOSE
Definition: winsock.h:410
#define SD_SEND
Definition: winsock.h:55
#define FD_CONNECT
Definition: winsock.h:409
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

◆ Exit()

static void Exit ( void  )
static

Definition at line 1330 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);
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
int32_t INT
Definition: typedefs.h:58
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

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(), _Function_class_(), _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(), IntFixUpDevModeNames(), KiNmiInterruptHandler(), LdrpCreateDllSection(), LdrpInitializeThread(), CSettings::Load(), load_truetype_glyph(), main(), MapAnsiQuerySetToUnicode(), MapUnicodeQuerySetToAnsi(), MiDoMappedCopy(), MiDoPoolCopy(), MmMapViewOfSection(), MmPapAllocatePagesInRange(), NtAreMappedFilesTheSame(), NtGdiExtEscape(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphOutline(), NtGdiSelectClipPath(), NtGdiSetDIBitsToDeviceInternal(), NtGdiSetPixelFormat(), NtGdiSwapBuffers(), NtSetSystemPowerState(), NtStopProfile(), NtUserAttachThreadInput(), NtUserBuildPropList(), NtUserCallHwndLock(), NtUserCallHwndParamLock(), NtUserCallNextHookEx(), NtUserCloseDesktop(), NtUserCopyAcceleratorTable(), NtUserCreateAcceleratorTable(), NtUserCreateCaret(), NtUserCreateDesktop(), NtUserDeferWindowPos(), NtUserDefSetText(), NtUserDestroyMenu(), NtUserDragDetect(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), NtUserFillWindow(), NtUserFindWindowEx(), NtUserFlashWindowEx(), NtUserGetClipCursor(), NtUserGetComboBoxInfo(), NtUserGetDCEx(), NtUserGetGuiResources(), NtUserGetGUIThreadInfo(), NtUserGetInternalWindowPos(), NtUserGetLayeredWindowAttributes(), NtUserGetListBoxInfo(), NtUserGetMenuIndex(), NtUserGetMenuItemRect(), NtUserGetObjectInformation(), NtUserGetScrollBarInfo(), NtUserGetSystemMenu(), NtUserGetUpdateRect(), NtUserGetWindowPlacement(), NtUserHideCaret(), NtUserHiliteMenuItem(), NtUserInternalGetWindowText(), NtUserMenuItemFromPoint(), NtUserMinMaximize(), NtUserPrintWindow(), NtUserQueryWindow(), NtUserRedrawWindow(), NtUserRegisterWindowMessage(), NtUserRemoveProp(), NtUserSBGetParms(), NtUserScrollDC(), NtUserSetActiveWindow(), NtUserSetCursorIconData(), NtUserSetFocus(), NtUserSetInternalWindowPos(), NtUserSetLayeredWindowAttributes(), NtUserSetMenu(), NtUserSetProp(), NtUserSetShellWindowEx(), NtUserSetSystemCursor(), NtUserSetSystemMenu(), NtUserSetWindowFNID(), NtUserSetWindowPlacement(), NtUserSetWindowPos(), NtUserSetWindowRgn(), NtUserSetWindowWord(), NtUserShowCaret(), NtUserShowWindow(), NtUserShowWindowAsync(), NtUserSwitchDesktop(), NtUserTrackPopupMenuEx(), NtUserUnhookWindowsHookEx(), NtUserUpdateLayeredWindow(), NtUserValidateHandleSecure(), 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_skip_PS_token(), ps_parser_to_bytes(), ps_table_new(), ps_tocoordarray(), ps_tofixedarray(), psh_glyph_init(), psh_hint_table_init(), RegCreateKeyExA(), RegEnumKeyExA(), RegEnumValueA(), RegLoadKeyA(), RegOpenKeyExW(), RegReplaceKeyA(), RtlGetNtProductType(), RtlpLookupDynamicFunctionEntry(), RtlVirtualUnwind(), SetDIBitsToDevice(), sfnt_load_face(), SRomFindMasterAdapter(), SRomRegisterMasterAdapter(), 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(), Test_Overread(), 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 361 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 );
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define memset(x, y, z)
Definition: compat.h:39
#define FIRST_CHAR
Definition: sock.c:47

Referenced by client_start().

◆ flush_events()

static void flush_events ( SOCKET  s,
HANDLE  hEvent 
)
static

Definition at line 5821 of file sock.c.

5824{
5825 WSANETWORKEVENTS netEvents;
5826 struct async_message *prev = NULL, *curr = messages_received;
5827 int ret;
5828 DWORD dwRet;
5829
5831 {
5832 dwRet = WaitForSingleObject(hEvent, 100);
5833 if (dwRet == WAIT_OBJECT_0)
5834 {
5835 ret = WSAEnumNetworkEvents(s, hEvent, &netEvents);
5836 if (ret)
5837 ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5838 }
5839 }
5840 else
5841 {
5842 while (curr)
5843 {
5844 if (curr->socket == s)
5845 {
5846 if (prev) prev->next = curr->next;
5847 else messages_received = curr->next;
5848
5849 HeapFree(GetProcessHeap(), 0, curr);
5850
5851 if (prev) curr = prev->next;
5852 else curr = messages_received;
5853 }
5854 else
5855 {
5856 prev = curr;
5857 curr = curr->next;
5858 }
5859 }
#define GetProcessHeap()
Definition: compat.h:736
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapFree(x, y, z)
Definition: compat.h:735
static HANDLE hEvent
Definition: comm.c:54

◆ get_event_details()

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

Definition at line 5724 of file sock.c.

5727{
5728 switch (event)
5729 {
5730 case FD_ACCEPT:
5731 if (bit) *bit = FD_ACCEPT_BIT;
5732 if (name) strcpy(name, "FD_ACCEPT");
5733 break;
5734 case FD_CONNECT:
5735 if (bit) *bit = FD_CONNECT_BIT;
5736 if (name) strcpy(name, "FD_CONNECT");
5737 break;
5738 case FD_READ:
5739 if (bit) *bit = FD_READ_BIT;
5740 if (name) strcpy(name, "FD_READ");
5741 break;
5742 case FD_OOB:
5743 if (bit) *bit = FD_OOB_BIT;
5744 if (name) strcpy(name, "FD_OOB");
5745 break;
5746 case FD_WRITE:
5747 if (bit) *bit = FD_WRITE_BIT;
5748 if (name) strcpy(name, "FD_WRITE");
5749 break;
5750 case FD_CLOSE:
5751 if (bit) *bit = FD_CLOSE_BIT;
5752 if (name) strcpy(name, "FD_CLOSE");
5753 break;
5754 default:
5755 if (bit) *bit = -1;
5756 if (name) sprintf(name, "bad%x", event);
#define FD_OOB_BIT
Definition: winsock2.h:297
#define FD_ACCEPT_BIT
Definition: winsock2.h:299
#define FD_OOB
Definition: winsock.h:407
#define FD_ACCEPT
Definition: winsock.h:408

◆ gethostname()

int WINAPI gethostname ( char name,
int  namelen 
)

Referenced by test_gethostbyname().

◆ inet_ntoa_thread_proc()

static DWORD WINAPI inet_ntoa_thread_proc ( void param)
static

Definition at line 10743 of file sock.c.

10746{
10747 ULONG addr;
10748 const char *str;
10749 HANDLE *event = param;
10750
10751 addr = inet_addr("4.3.2.1");
10752 ok(addr == htonl(0x04030201), "expected 0x04030201, got %08x\n", addr);
10753 str = inet_ntoa(*(struct in_addr *)&addr);
10754 ok(!strcmp(str, "4.3.2.1"), "expected 4.3.2.1, got %s\n", str);
10755
10756 SetEvent(event[0]);
10757 WaitForSingleObject(event[1], 3000);
10758
CHAR FAR *WSAAPI inet_ntoa(IN IN_ADDR in)
Definition: addrconv.c:160
#define htonl(x)
Definition: module.h:214
const WCHAR * str
Definition: tcpip.h:126
uint32_t ULONG
Definition: typedefs.h:59

◆ Init()

static void Init ( void  )
static

Definition at line 1287 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 p_inet_ntop = (void *)GetProcAddress(hws2_32, "inet_ntop");
1302 pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
1303 p_inet_pton = (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();
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
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
#define MAKEWORD(a, b)
Definition: typedefs.h:248

◆ 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 6933 of file sock.c.

6936{

◆ iocp_async_closesocket()

static void iocp_async_closesocket ( SOCKET  src)
static

Definition at line 11344 of file sock.c.

11347{
11348 HANDLE port;
11349 WSAOVERLAPPED *ovl_iocp;
11350 int ret;
11351 DWORD bytes;
11352 ULONG_PTR key;
11353 HWND hwnd;
11354 MSG msg;
11355
11356 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11357 0, 0, 0, 0, NULL, NULL, 0, NULL);
11358 ok(hwnd != 0, "CreateWindowEx failed\n");
11359
11361 ok(!ret, "got %d\n", ret);
11362
11363 Sleep(100);
11364 memset(&msg, 0, sizeof(msg));
11366 ok(ret, "got %d\n", ret);
11367 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11368 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11369 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11370 ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11371
11372 port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11373 ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11374
11375 Sleep(100);
11377 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11378
11379 bytes = 0xdeadbeef;
11380 key = 0xdeadbeef;
11381 ovl_iocp = (void *)0xdeadbeef;
11382 SetLastError(0xdeadbeef);
11383 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11384 ok(!ret, "got %d\n", ret);
11385 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11386 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11387 ok(key == 0xdeadbeef, "got key %lu\n", key);
11388 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11389
11390 Sleep(100);
11392 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11393
11395
11396 Sleep(100);
11397 memset(&msg, 0, sizeof(msg));
11399 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11400
11401 bytes = 0xdeadbeef;
11402 key = 0xdeadbeef;
11403 ovl_iocp = (void *)0xdeadbeef;
11404 SetLastError(0xdeadbeef);
11405 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11406 ok(!ret, "got %d\n", ret);
11407 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11408 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11409 ok(key == 0xdeadbeef, "got key %lu\n", key);
11410 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11411
11413
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define SetLastError(x)
Definition: compat.h:752
INT WSAAPI WSAAsyncSelect(IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent)
Definition: select.c:134
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
BOOL WINAPI GetQueuedCompletionStatus(IN HANDLE CompletionHandle, IN LPDWORD lpNumberOfBytesTransferred, OUT PULONG_PTR lpCompletionKey, OUT LPOVERLAPPED *lpOverlapped, IN DWORD dwMilliseconds)
Definition: iocompl.c:131
#define WS_POPUP
Definition: pedump.c:616
#define WM_SOCKET
Definition: sock.c:5697
Definition: copy.c:22
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
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:1199
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)

◆ iocp_async_read()

static void iocp_async_read ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 11133 of file sock.c.

11136{
11137 HANDLE port;
11138 WSAOVERLAPPED ovl, *ovl_iocp;
11139 WSABUF buf;
11140 int ret;
11141 char data[512];
11142 DWORD flags, bytes;
11143 ULONG_PTR key;
11144
11145 memset(data, 0, sizeof(data));
11146 memset(&ovl, 0, sizeof(ovl));
11147
11148 port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11149 ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11150
11151 buf.len = sizeof(data);
11152 buf.buf = data;
11153 bytes = 0xdeadbeef;
11154 flags = 0;
11155 SetLastError(0xdeadbeef);
11156 ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL);
11157 ok(ret == SOCKET_ERROR, "got %d\n", ret);
11158 ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
11159 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11160
11161 bytes = 0xdeadbeef;
11162 key = 0xdeadbeef;
11163 ovl_iocp = (void *)0xdeadbeef;
11164 SetLastError(0xdeadbeef);
11165 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11166 ok(!ret, "got %d\n", ret);
11167 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11168 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11169 ok(key == 0xdeadbeef, "got key %#lx\n", key);
11170 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11171
11172 ret = send(dst, "Hello World!", 12, 0);
11173 ok(ret == 12, "send returned %d\n", ret);
11174
11175 bytes = 0xdeadbeef;
11176 key = 0xdeadbeef;
11177 ovl_iocp = NULL;
11178 SetLastError(0xdeadbeef);
11179 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11180 ok(ret, "got %d\n", ret);
11181 ok(bytes == 12, "got bytes %u\n", bytes);
11182 ok(key == 0x12345678, "got key %#lx\n", key);
11183 ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp);
11184 if (ovl_iocp)
11185 {
11186 ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh);
11187 ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal);
11188 ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data);
11189 }
11190
11191 bytes = 0xdeadbeef;
11192 key = 0xdeadbeef;
11193 ovl_iocp = (void *)0xdeadbeef;
11194 SetLastError(0xdeadbeef);
11195 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11196 ok(!ret, "got %d\n", ret);
11197 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11198 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11199 ok(key == 0xdeadbeef, "got key %#lx\n", key);
11200 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11201
#define ERROR_IO_PENDING
Definition: dderror.h:15
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
GLenum GLenum dst
Definition: glext.h:6340
DWORD InternalHigh
Definition: winsock2.h:610
DWORD Internal
Definition: winsock2.h:609
#define SOCKET_ERROR
Definition: winsock.h:333

◆ iocp_async_read_closesocket()

static void iocp_async_read_closesocket ( SOCKET  src,
int  how_to_close 
)
static

Definition at line 11203 of file sock.c.

11206{
11207 HANDLE port;
11208 WSAOVERLAPPED ovl, *ovl_iocp;
11209 WSABUF buf;
11210 int ret;
11211 char data[512];
11212 DWORD flags, bytes;
11213 ULONG_PTR key;
11214 HWND hwnd;
11215 MSG msg;
11216
11217 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11218 0, 0, 0, 0, NULL, NULL, 0, NULL);
11219 ok(hwnd != 0, "CreateWindowEx failed\n");
11220
11222 ok(!ret, "got %d\n", ret);
11223
11224 Sleep(100);
11225 memset(&msg, 0, sizeof(msg));
11227 ok(ret, "got %d\n", ret);
11228 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11229 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11230 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11231 ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11232
11233 memset(data, 0, sizeof(data));
11234 memset(&ovl, 0, sizeof(ovl));
11235
11236 port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11237 ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11238
11239 Sleep(100);
11241 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11242
11243 buf.len = sizeof(data);
11244 buf.buf = data;
11245 bytes = 0xdeadbeef;
11246 flags = 0;
11247 SetLastError(0xdeadbeef);
11248 ret = WSARecv(src, &buf, 1, &bytes, &flags, &ovl, NULL);
11249 ok(ret == SOCKET_ERROR, "got %d\n", ret);
11250 ok(GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
11251 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11252
11253 Sleep(100);
11255 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11256
11257 bytes = 0xdeadbeef;
11258 key = 0xdeadbeef;
11259 ovl_iocp = (void *)0xdeadbeef;
11260 SetLastError(0xdeadbeef);
11261 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11262 ok(!ret, "got %d\n", ret);
11263 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11264 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11265 ok(key == 0xdeadbeef, "got key %#lx\n", key);
11266 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11267
11268 Sleep(100);
11270 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11271
11272 switch (how_to_close)
11273 {
11274 case 0:
11276 break;
11277 case 1:
11279 break;
11280 case 2:
11281 pNtClose((HANDLE)src);
11282 break;
11283 default:
11284 ok(0, "wrong value %d\n", how_to_close);
11285 break;
11286 }
11287
11288 Sleep(200);
11289 memset(&msg, 0, sizeof(msg));
11291 switch (how_to_close)
11292 {
11293 case 0:
11294 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11295 break;
11296 case 1:
11297 case 2:
11299{
11300 ok(ret, "got %d\n", ret);
11301 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11302 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11303 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11304 ok(msg.lParam == 0x20, "got %08lx\n", msg.lParam);
11305}
11306 break;
11307 default:
11308 ok(0, "wrong value %d\n", how_to_close);
11309 break;
11310 }
11311
11312 bytes = 0xdeadbeef;
11313 key = 0xdeadbeef;
11314 ovl_iocp = NULL;
11315 SetLastError(0xdeadbeef);
11316 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11317 ok(!ret, "got %d\n", ret);
11320 ok(!bytes, "got bytes %u\n", bytes);
11321 ok(key == 0x12345678, "got key %#lx\n", key);
11322 ok(ovl_iocp == &ovl, "got ovl %p\n", ovl_iocp);
11323 if (ovl_iocp)
11324 {
11325 ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11327 ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11328 }
11329
11330 bytes = 0xdeadbeef;
11331 key = 0xdeadbeef;
11332 ovl_iocp = (void *)0xdeadbeef;
11333 SetLastError(0xdeadbeef);
11334 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11335 ok(!ret, "got %d\n", ret);
11336 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11337 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11338 ok(key == 0xdeadbeef, "got key %#lx\n", key);
11339 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11340
11342
#define todo_wine
Definition: custom.c:89
#define STATUS_CONNECTION_ABORTED
Definition: ntstatus.h:709
#define STATUS_LOCAL_DISCONNECT
Definition: ntstatus.h:551
#define ERROR_CONNECTION_ABORTED
Definition: winerror.h:739
#define ERROR_NETNAME_DELETED
Definition: winerror.h:156

◆ iocp_async_read_thread()

static void iocp_async_read_thread ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 11584 of file sock.c.

11587{
11588 struct wsa_async_select_info select_info;
11589 struct wsa_recv_info recv_info;
11591 WSAOVERLAPPED *ovl_iocp;
11592 int ret;
11593 char data[512];
11594 DWORD bytes, tid;
11595 ULONG_PTR key;
11596 HWND hwnd;
11597 MSG msg;
11598
11599 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11600 0, 0, 0, 0, NULL, NULL, 0, NULL);
11601 ok(hwnd != 0, "CreateWindowEx failed\n");
11602
11603 select_info.sock = src;
11604 select_info.hwnd = hwnd;
11605 thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11606 ok(thread != 0, "CreateThread error %u\n", GetLastError());
11607 ret = WaitForSingleObject(thread, 10000);
11608 ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11609
11610 Sleep(100);
11611 memset(&msg, 0, sizeof(msg));
11613 ok(ret, "got %d\n", ret);
11614 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11615 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11616 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11617 ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11618
11619 port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11620 ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11621
11622 Sleep(100);
11624 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11625
11626 memset(data, 0, sizeof(data));
11627 memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11628 recv_info.sock = src;
11629 recv_info.wsa_buf.len = sizeof(data);
11630 recv_info.wsa_buf.buf = data;
11631 thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11632 ok(thread != 0, "CreateThread error %u\n", GetLastError());
11633 ret = WaitForSingleObject(thread, 10000);
11634 ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11635
11636 Sleep(100);
11638 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11639
11640 bytes = 0xdeadbeef;
11641 key = 0xdeadbeef;
11642 ovl_iocp = (void *)0xdeadbeef;
11643 SetLastError(0xdeadbeef);
11644 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11645 ok(!ret, "got %d\n", ret);
11647 if (GetLastError() == WAIT_TIMEOUT)
11648 {
11649 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11650 ok(key == 0xdeadbeef, "got key %lu\n", key);
11651 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11652 }
11653 else /* document XP behaviour */
11654 {
11655 ok(bytes == 0, "got bytes %u\n", bytes);
11656 ok(key == 0x12345678, "got key %#lx\n", key);
11657 ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11658 if (ovl_iocp)
11659 {
11660 ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11661 ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11662 }
11663 }
11664
11665 Sleep(100);
11666 memset(&msg, 0, sizeof(msg));
11668 ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11669 if (ret) /* document XP behaviour */
11670 {
11671 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11672 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11673 ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11674 }
11675
11676 ret = send(dst, "Hello World!", 12, 0);
11677 ok(ret == 12, "send returned %d\n", ret);
11678
11679 Sleep(100);
11680 memset(&msg, 0, sizeof(msg));
11682 ok(!ret || broken(msg.hwnd == hwnd) /* XP */, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11683 if (ret) /* document XP behaviour */
11684 {
11685 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11686 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11687 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11688 ok(msg.lParam == 1, "got %08lx\n", msg.lParam);
11689 }
11690
11691 bytes = 0xdeadbeef;
11692 key = 0xdeadbeef;
11693 ovl_iocp = (void *)0xdeadbeef;
11694 SetLastError(0xdeadbeef);
11695 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11696 ok(ret || broken(GetLastError() == WAIT_TIMEOUT) /* XP */, "got %u\n", GetLastError());
11697 if (ret)
11698 {
11699 ok(bytes == 12, "got bytes %u\n", bytes);
11700 ok(key == 0x12345678, "got key %#lx\n", key);
11701 ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11702 if (ovl_iocp)
11703 {
11704 ok(ovl_iocp->InternalHigh == 12, "got %#lx\n", ovl_iocp->InternalHigh);
11705 ok(!ovl_iocp->Internal , "got %#lx\n", ovl_iocp->Internal);
11706 ok(!memcmp(data, "Hello World!", 12), "got %u bytes (%*s)\n", bytes, bytes, data);
11707 }
11708 }
11709 else /* document XP behaviour */
11710 {
11711 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11712 ok(key == 0xdeadbeef, "got key %lu\n", key);
11713 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11714 }
11715
11717
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
static TfClientId tid
static DWORD WINAPI wsa_recv_thread(void *param)
Definition: sock.c:11439
static DWORD WINAPI wsa_async_select_thread(void *param)
Definition: sock.c:11421
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define ERROR_OPERATION_ABORTED
Definition: winerror.h:575

◆ iocp_async_read_thread_closesocket()

static void iocp_async_read_thread_closesocket ( SOCKET  src)
static

Definition at line 11456 of file sock.c.

11459{
11460 struct wsa_async_select_info select_info;
11461 struct wsa_recv_info recv_info;
11463 WSAOVERLAPPED *ovl_iocp;
11464 int ret;
11465 char data[512];
11466 DWORD bytes, tid;
11467 ULONG_PTR key;
11468 HWND hwnd;
11469 MSG msg;
11470
11471 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
11472 0, 0, 0, 0, NULL, NULL, 0, NULL);
11473 ok(hwnd != 0, "CreateWindowEx failed\n");
11474
11475 select_info.sock = src;
11476 select_info.hwnd = hwnd;
11477 thread = CreateThread(NULL, 0, wsa_async_select_thread, &select_info, 0, &tid);
11478 ok(thread != 0, "CreateThread error %u\n", GetLastError());
11479 ret = WaitForSingleObject(thread, 10000);
11480 ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11481
11482 Sleep(100);
11483 memset(&msg, 0, sizeof(msg));
11485 ok(ret, "got %d\n", ret);
11486 ok(msg.hwnd == hwnd, "got %p\n", msg.hwnd);
11487 ok(msg.message == WM_SOCKET, "got %04x\n", msg.message);
11488 ok(msg.wParam == src, "got %08lx\n", msg.wParam);
11489 ok(msg.lParam == 2, "got %08lx\n", msg.lParam);
11490
11491 port = CreateIoCompletionPort((HANDLE)src, 0, 0x12345678, 0);
11492 ok(port != 0, "CreateIoCompletionPort error %u\n", GetLastError());
11493
11494 Sleep(100);
11496 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11497
11498 memset(data, 0, sizeof(data));
11499 memset(&recv_info.ovl, 0, sizeof(recv_info.ovl));
11500 recv_info.sock = src;
11501 recv_info.wsa_buf.len = sizeof(data);
11502 recv_info.wsa_buf.buf = data;
11503 thread = CreateThread(NULL, 0, wsa_recv_thread, &recv_info, 0, &tid);
11504 ok(thread != 0, "CreateThread error %u\n", GetLastError());
11505 ret = WaitForSingleObject(thread, 10000);
11506 ok(ret == WAIT_OBJECT_0, "thread failed to terminate\n");
11507
11508 Sleep(100);
11510 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11511
11512 bytes = 0xdeadbeef;
11513 key = 0xdeadbeef;
11514 ovl_iocp = (void *)0xdeadbeef;
11515 SetLastError(0xdeadbeef);
11516 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11517 ok(!ret, "got %d\n", ret);
11519 "got %u\n", GetLastError());
11520 if (GetLastError() == WAIT_TIMEOUT)
11521 {
11522 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11523 ok(key == 0xdeadbeef, "got key %lx\n", key);
11524 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11525 }
11526 else /* document XP behaviour */
11527 {
11528 ok(!bytes, "got bytes %u\n", bytes);
11529 ok(key == 0x12345678, "got key %#lx\n", key);
11530 ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11531 if (ovl_iocp)
11532 {
11533 ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11534 ok(ovl_iocp->Internal == STATUS_CANCELLED, "got %#lx\n", ovl_iocp->Internal);
11535 }
11536
11538 goto xp_is_broken;
11539 }
11540
11541 Sleep(100);
11543 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11544
11546
11547 Sleep(100);
11549 ok(!ret, "got %04x,%08lx,%08lx\n", msg.message, msg.wParam, msg.lParam);
11550
11551 bytes = 0xdeadbeef;
11552 key = 0xdeadbeef;
11553 ovl_iocp = NULL;
11554 SetLastError(0xdeadbeef);
11555 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11556 ok(!ret, "got %d\n", ret);
11559 ok(!bytes, "got bytes %u\n", bytes);
11560 ok(key == 0x12345678, "got key %#lx\n", key);
11561 ok(ovl_iocp == &recv_info.ovl, "got ovl %p\n", ovl_iocp);
11562 if (ovl_iocp)
11563 {
11564 ok(!ovl_iocp->InternalHigh, "got %#lx\n", ovl_iocp->InternalHigh);
11566 ok(ovl_iocp->Internal == (ULONG)STATUS_CONNECTION_ABORTED || ovl_iocp->Internal == (ULONG)STATUS_LOCAL_DISCONNECT /* XP */, "got %#lx\n", ovl_iocp->Internal);
11567 }
11568
11569xp_is_broken:
11570 bytes = 0xdeadbeef;
11571 key = 0xdeadbeef;
11572 ovl_iocp = (void *)0xdeadbeef;
11573 SetLastError(0xdeadbeef);
11574 ret = GetQueuedCompletionStatus(port, &bytes, &key, &ovl_iocp, 100);
11575 ok(!ret, "got %d\n", ret);
11576 ok(GetLastError() == WAIT_TIMEOUT, "got %u\n", GetLastError());
11577 ok(bytes == 0xdeadbeef, "got bytes %u\n", bytes);
11578 ok(key == 0xdeadbeef, "got key %lu\n", key);
11579 ok(!ovl_iocp, "got ovl %p\n", ovl_iocp);
11580
11582

◆ match_event_sequence()

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

Definition at line 5861 of file sock.c.

5864{
5865 int event, index, error, events;
5866 struct async_message *curr;
5867
5868 if (netEvents)
5869 {
5870 events = netEvents->lNetworkEvents;
5871 while (*seq)
5872 {
5873 event = WSAGETSELECTEVENT(*seq);
5874 error = WSAGETSELECTERROR(*seq);
5876
5877 if (!(events & event) && index != -1)
5878 return 0;
5879 if (events & event && index != -1)
5880 {
5881 if (netEvents->iErrorCode[index] != error)
5882 return 0;
5883 }
5884 events &= ~event;
5885 seq++;
5886 }
5887 if (events)
5888 return 0;
5889 }
5890 else
5891 {
5892 curr = messages_received;
5893 while (curr)
5894 {
5895 if (curr->socket == s)
5896 {
5897 if (!*seq) return 0;
5898 if (*seq != curr->lparam) return 0;
5899 seq++;
5900 }
5901 curr = curr->next;
5902 }
5903 if (*seq)
5904 return 0;
5905 }
HANDLE events[2]
Definition: event.c:4

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 5908 of file sock.c.

5911{
5912 MSG msg;
5913 WSANETWORKEVENTS events, *netEvents = NULL;
5914 int ret;
5915 DWORD dwRet;
5916
5918 {
5919 netEvents = &events;
5920
5921 dwRet = WaitForSingleObject(hEvent, 200);
5922 if (dwRet == WAIT_OBJECT_0)
5923 {
5924 ret = WSAEnumNetworkEvents(s, hEvent, netEvents);
5925 if (ret)
5926 {
5927 winetest_ok(0, "WSAEnumNetworkEvents failed, error %d\n", ret);
5928 return;
5929 }
5930 }
5931 else
5932 memset(netEvents, 0, sizeof(*netEvents));
5933 }
5934 else
5935 {
5936 Sleep(200);
5937 /* Run the message loop a little */
5938 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
5939 {
5941 }
5942 }
5943
5944 if (match_event_sequence(s, netEvents, seq))
5945 {
5946 winetest_ok(1, "Sequence matches expected: %s\n", dbgstr_event_seq(seq));
5948 return;
5949 }
5950
5951 if (broken_seqs)
5952 {
5953 for (; *broken_seqs; broken_seqs++)
5954 {
5955 if (match_event_sequence(s, netEvents, *broken_seqs))
5956 {
5957 winetest_ok(broken(1), "Sequence matches broken: %s, expected %s\n", dbgstr_event_seq_result(s, netEvents), dbgstr_event_seq(seq));
5959 return;
5960 }
5961 }
5962 }
5963
5964 winetest_ok(broken(completelyBroken), "Expected event sequence %s, got %s\n", dbgstr_event_seq(seq),
5965 dbgstr_event_seq_result(s, netEvents));
static void flush_events(void)
Definition: SystemMenu.c:167
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
static char * dbgstr_event_seq_result(SOCKET s, WSANETWORKEVENTS *netEvents)
Definition: sock.c:5777
static const char * dbgstr_event_seq(const LPARAM *seq)
Definition: sock.c:5758
static int match_event_sequence(SOCKET s, WSANETWORKEVENTS *netEvents, const LPARAM *seq)
Definition: sock.c:5861
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)

◆ oob_client()

static VOID WINAPI oob_client ( client_params par)
static

Definition at line 921 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 ();
GLuint id
Definition: glext.h:5910
static void read_zero_bytes(SOCKET s)
Definition: sock.c:384
static int do_synchronous_send(SOCKET s, char *buf, int buflen, int flags, int sendlen)
Definition: sock.c:393
static int set_blocking(SOCKET s, BOOL blocking)
Definition: sock.c:355
static void check_so_opentype(void)
Definition: sock.c:436
static void set_so_opentype(BOOL overlapped)
Definition: sock.c:342
static int do_synchronous_recv(SOCKET s, char *buf, int buflen, int flags, int recvlen)
Definition: sock.c:406
#define MSG_OOB
Definition: winsock.h:221

◆ oob_server()

static VOID WINAPI oob_server ( server_params par)
static

Definition at line 663 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 ();
unsigned long u_long
Definition: linux.h:269
#define ioctlsocket
Definition: ncftp.h:481
static void server_stop(void)
Definition: sock.c:548
static void server_start(server_params *par)
Definition: sock.c:521
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
test_params * general
Definition: sock.c:140
int buflen
Definition: sock.c:142
#define SOMAXCONN
Definition: winsock.h:399
#define SIOCATMARK
Definition: winsock.h:253

◆ PCSTR()

static PCSTR ( WINAPI p_inet_ntop)
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 7316 of file sock.c.

7316 {fds[ix].fd = s; fds[ix++].events = ev;}
7317#define POLL_ISSET(s, rev) poll_isset(fds, ix, s, rev)
7318static BOOL poll_isset(WSAPOLLFD *fds, int max, SOCKET s, int rev)
7319{
7320 int k;
7321 for (k = 0; k < max; k++)
7322 if (fds[k].fd == s && (fds[k].revents == rev)) return TRUE;
int rev
Definition: sort.c:17
static int fd
Definition: io.c:51
static BOOL poll_isset(WSAPOLLFD *fds, int max, SOCKET s, int rev)
Definition: sock.c:7316
#define max(a, b)
Definition: svc.c:63

◆ read_zero_bytes()

static void read_zero_bytes ( SOCKET  s)
static

Definition at line 384 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 );

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 6913 of file sock.c.

6916{
6917 SOCKET sock = *(SOCKET *)arg;
6918 char buffer[32];
6919 WSABUF wsa;
6920 WSAOVERLAPPED ov;
6921 DWORD flags = 0;
6922
6923 wsa.buf = buffer;
6924 wsa.len = sizeof(buffer);
6925 ov.hEvent = WSACreateEvent();
6926 WSARecv(sock, &wsa, 1, NULL, &flags, &ov, NULL);
6927
6928 WaitForSingleObject(ov.hEvent, 1000);
ULONG len
Definition: ws2def.h:519
CHAR FAR * buf
Definition: ws2def.h:520
WSAEVENT hEvent
Definition: winsock2.h:613

◆ select_server()

static VOID WINAPI select_server ( server_params par)
static

Definition at line 739 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 ();
u_int fd_count
Definition: winsock.h:67
Definition: dhcpd.h:245
#define FD_ISSET(fd, set)
Definition: winsock.h:100
#define FD_CLR(fd, set)
Definition: winsock.h:74

◆ SelectCloseThread()

static DWORD WINAPI SelectCloseThread ( void param)
static

Definition at line 3648 of file sock.c.

3651{
3652 SOCKET s = *(SOCKET*)param;
3653 Sleep(500);
3654 closesocket(s);

Referenced by test_select().

◆ SelectReadThread()

static DWORD WINAPI SelectReadThread ( void param)
static

Definition at line 3621 of file sock.c.

3624{
3626 fd_set readfds;
3627 int ret;
3628 struct sockaddr_in addr;
3629 struct timeval select_timeout;
3630
3631 memset(&readfds, 0, sizeof(readfds));
3632 FD_ZERO(&readfds);
3633 FD_SET(par->s, &readfds);
3634 select_timeout.tv_sec=5;
3635 select_timeout.tv_usec=0;
3636 addr.sin_family = AF_INET;
3637 addr.sin_addr.s_addr = inet_addr(SERVERIP);
3638 addr.sin_port = htons(SERVERPORT);
3639
3640 do_bind(par->s, (struct sockaddr *)&addr, sizeof(addr));
3641 wsa_ok(listen(par->s, SOMAXCONN ), 0 ==, "SelectReadThread (%x): listen failed: %d\n");
3642
3644 ret = select(par->s+1, &readfds, NULL, NULL, &select_timeout);
3645 par->ReadKilled = (ret == 1);
3646
static void do_bind(SOCKET s, struct sockaddr *addr, int addrlen)
Definition: sock.c:507

Referenced by test_select().

◆ server_start()

static void server_start ( server_params par)
static

Definition at line 521 of file sock.c.

523{
524 int i;
525 test_params *gen = par->general;
526 server_memory *mem = LocalAlloc ( LPTR, sizeof ( server_memory ) );
527
528 TlsSetValue ( tls, mem );
529 mem->s = WSASocketA ( AF_INET, gen->sock_type, gen->sock_prot,
530 NULL, 0, par->sock_flags );
531 ok ( mem->s != INVALID_SOCKET, "Server: WSASocket failed\n" );
532
533 mem->addr.sin_family = AF_INET;
534 mem->addr.sin_addr.s_addr = inet_addr ( gen->inet_addr );
535 mem->addr.sin_port = htons ( gen->inet_port );
536
537 for (i = 0; i < MAX_CLIENTS; i++)
538 {
539 mem->sock[i].s = INVALID_SOCKET;
540 mem->sock[i].buf = LocalAlloc ( LPTR, gen->n_chunks * gen->chunk_size );
541 mem->sock[i].n_recvd = 0;
542 mem->sock[i].n_sent = 0;
543 }
544
545 if ( gen->sock_type == SOCK_STREAM )
546 do_bind ( mem->s, (struct sockaddr*) &mem->addr, sizeof (mem->addr) );
DWORD sock_flags
Definition: sock.c:141

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

◆ server_stop()

static void server_stop ( void  )
static

Definition at line 548 of file sock.c.

550{
551 int i;
553
554 for (i = 0; i < MAX_CLIENTS; i++ )
555 {
556 LocalFree ( mem->sock[i].buf );
557 if ( mem->sock[i].s != INVALID_SOCKET )
558 closesocket ( mem->sock[i].s );
559 }
560 ok ( closesocket ( mem->s ) == 0, "closesocket failed\n" );
561 LocalFree ( mem );

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

◆ set_blocking()

static int set_blocking ( SOCKET  s,
BOOL  blocking 
)
static

Definition at line 355 of file sock.c.

357{
358 u_long val = !blocking;
359 return ioctlsocket ( s, FIONBIO, &val );
GLuint GLfloat * val
Definition: glext.h:7180
#define FIONBIO
Definition: winsock.h:149

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

◆ set_so_opentype()

static void set_so_opentype ( BOOL  overlapped)
static

Definition at line 342 of file sock.c.

344{
345 int optval = !overlapped, newval, len = sizeof (int);
346
348 (LPVOID) &optval, sizeof (optval) ) == 0,
349 "setting SO_OPENTYPE failed\n" );
351 (LPVOID) &newval, &len ) == 0,
352 "getting SO_OPENTYPE failed\n" );
353 ok ( optval == newval, "failed to set SO_OPENTYPE\n" );
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:81
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421

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

◆ setup_connector_socket()

static SOCKET setup_connector_socket ( struct sockaddr_in addr,
int  len,
BOOL  nonblock 
)
static

Definition at line 4227 of file sock.c.

4230{
4231 int ret;
4232 SOCKET connector;
4233
4234 connector = socket(AF_INET, SOCK_STREAM, 0);
4235 ok(connector != INVALID_SOCKET, "failed to create connector socket %d\n", WSAGetLastError());
4236
4237 if (nonblock)
4238 set_blocking(connector, !nonblock);
4239
4240 ret = connect(connector, (struct sockaddr *)addr, len);
4241 if (!nonblock)
4242 ok(!ret, "connecting to accepting socket failed %d\n", WSAGetLastError());
4243 else if (ret == SOCKET_ERROR)
4244 {
4247 "expected 10035 or 10036, got %d\n", error);
4248 }
4249
static int nonblock(int fd, int isnonblock)
Definition: adnsresfilter.c:86
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define WSAEINPROGRESS
Definition: winerror.h:1949

Referenced by test_select().

◆ setup_iocp_src()

static SOCKET setup_iocp_src ( struct sockaddr_in bindAddress)
static

Definition at line 9810 of file sock.c.

9813{
9815 int iret, socklen;
9816
9818 if (src == INVALID_SOCKET)
9819 {
9820 skip("could not create listener socket, error %d\n", WSAGetLastError());
9821 goto end;
9822 }
9823
9824 memset(bindAddress, 0, sizeof(*bindAddress));
9825 bindAddress->sin_family = AF_INET;
9826 bindAddress->sin_addr.s_addr = inet_addr("127.0.0.1");
9827 iret = bind(src, (struct sockaddr*)bindAddress, sizeof(*bindAddress));
9828 if (iret != 0)
9829 {
9830 skip("failed to bind, error %d\n", WSAGetLastError());
9831 goto end;
9832 }
9833
9834 socklen = sizeof(*bindAddress);
9835 iret = getsockname(src, (struct sockaddr*)bindAddress, &socklen);
9836 if (iret != 0) {
9837 skip("failed to lookup bind address, error %d\n", WSAGetLastError());
9838 goto end;
9839 }
9840
9841 if (set_blocking(src, FALSE))
9842 {
9843 skip("couldn't make socket non-blocking, error %d\n", WSAGetLastError());
9844 goto end;
9845 }
9846
9847 iret = listen(src, 5);
9848 if (iret != 0)
9849 {
9850 skip("listening failed, errno = %d\n", WSAGetLastError());
9851 goto end;
9852 }
9853
9854 ret = src;
9855end:
9856 if (src != ret && ret == INVALID_SOCKET)
#define skip(...)
Definition: atltest.h:64
GLuint GLuint end
Definition: gl.h:1545
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
struct in_addr sin_addr
Definition: winsock.h:512
short sin_family
Definition: winsock.h:510

◆ setup_server_socket()

static SOCKET setup_server_socket ( struct sockaddr_in addr,
int len 
)
static

Definition at line 4181 of file sock.c.

4184{
4185 int ret, val;
4187
4190 {
4191 trace("error creating server socket: %d\n", WSAGetLastError());
4192 return INVALID_SOCKET;
4193 }
4194
4195 val = 1;
4196 ret = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
4197 if (ret)
4198 {
4199 trace("error setting SO_REUSEADDR: %d\n", WSAGetLastError());
4201 return INVALID_SOCKET;
4202 }
4203
4204 ret = bind(server_socket, (struct sockaddr *)addr, *len);
4205 if (ret)
4206 {
4207 trace("error binding server socket: %d\n", WSAGetLastError());
4208 }
4209
4211 if (ret)
4212 {
4213 skip("failed to lookup bind address: %d\n", WSAGetLastError());
4215 return INVALID_SOCKET;
4216 }
4217
4218 ret = listen(server_socket, 5);
4219 if (ret)
4220 {
4221 trace("error making server socket listen: %d\n", WSAGetLastError());
4223 return INVALID_SOCKET;
4224 }
4225
static int server_socket
Definition: notification.c:641
#define SO_REUSEADDR
Definition: winsock.h:180

Referenced by test_select().

◆ simple_client()

static VOID WINAPI simple_client ( client_params par)
static

Definition at line 871 of file sock.c.

873{
874 test_params *gen = par->general;
876 int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
877
878 id = GetCurrentThreadId();
879 trace ( "simple_client (%x): starting\n", id );
880 /* wait here because we want to call set_so_opentype before creating a socket */
882 trace ( "simple_client (%x): server ready\n", id );
883
885 set_so_opentype ( FALSE ); /* non-overlapped */
886 client_start ( par );
887 mem = TlsGetValue ( tls );
888
889 /* Connect */
890 wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
891 0 ==, "simple_client (%x): connect error: %d\n" );
892 ok ( set_blocking ( mem->s, TRUE ) == 0,
893 "simple_client (%x): failed to set blocking mode\n", id );
894 trace ( "simple_client (%x) connected\n", id );
895
896 /* send data to server */
897 n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
898 ok ( n_sent == n_expected,
899 "simple_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
900
901 /* shutdown send direction */
902 wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
903
904 /* Receive data echoed back & check it */
905 n_recvd = do_synchronous_recv ( mem->s, mem->recv_buf, n_expected, 0, par->buflen );
906 ok ( n_recvd == n_expected,
907 "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
908
909 /* check data */
910 pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
911 ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
912
913 /* cleanup */
914 read_zero_bytes ( mem->s );
915 trace ( "simple_client (%x) exiting\n", id );
916 client_stop ();

◆ simple_mixed_client()

static VOID WINAPI simple_mixed_client ( client_params par)
static

Definition at line 974 of file sock.c.

976{
977 test_params *gen = par->general;
979 int pos, n_sent, n_recvd, n_expected = gen->n_chunks * gen->chunk_size, id;
980 int fromLen = sizeof(mem->addr);
981 struct sockaddr test;
982
983 id = GetCurrentThreadId();
984 trace ( "simple_client (%x): starting\n", id );
985 /* wait here because we want to call set_so_opentype before creating a socket */
987 trace ( "simple_client (%x): server ready\n", id );
988
990 set_so_opentype ( FALSE ); /* non-overlapped */
991 client_start ( par );
992 mem = TlsGetValue ( tls );
993
994 /* Connect */
995 wsa_ok ( connect ( mem->s, (struct sockaddr*) &mem->addr, sizeof ( mem->addr ) ),
996 0 ==, "simple_client (%x): connect error: %d\n" );
997 ok ( set_blocking ( mem->s, TRUE ) == 0,
998 "simple_client (%x): failed to set blocking mode\n", id );
999 trace ( "simple_client (%x) connected\n", id );
1000
1001 /* send data to server */
1002 n_sent = do_synchronous_send ( mem->s, mem->send_buf, n_expected, 0, par->buflen );
1003 ok ( n_sent == n_expected,
1004 "simple_client (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
1005
1006 /* shutdown send direction */
1007 wsa_ok ( shutdown ( mem->s, SD_SEND ), 0 ==, "simple_client (%x): shutdown failed: %d\n" );
1008
1009 /* this shouldn't change, since lpFrom, is not updated on
1010 connection oriented sockets - exposed by bug 11640
1011 */
1012 ((struct sockaddr_in*)&test)->sin_addr.s_addr = inet_addr("0.0.0.0");
1013
1014 /* Receive data echoed back & check it */
1015 n_recvd = do_synchronous_recvfrom ( mem->s,
1016 mem->recv_buf,
1017 n_expected,
1018 0,
1019 (struct sockaddr *)&test,
1020 &fromLen,
1021 par->buflen );
1022 ok ( n_recvd == n_expected,
1023 "simple_client (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
1024
1025 /* check that lpFrom was not updated */
1026 ok(0 ==
1027 strcmp(
1028 inet_ntoa(((struct sockaddr_in*)&test)->sin_addr),
1029 "0.0.0.0"), "lpFrom shouldn't be updated on connection oriented sockets\n");
1030
1031 /* check data */
1032 pos = test_buffer ( mem->recv_buf, gen->chunk_size, gen->n_chunks );
1033 ok ( pos == -1, "simple_client (%x): test pattern error: %d\n", id, pos);
1034
1035 /* cleanup */
1036 read_zero_bytes ( mem->s );
1037 trace ( "simple_client (%x) exiting\n", id );
1038 client_stop ();
static int do_synchronous_recvfrom(SOCKET s, char *buf, int buflen, int flags, struct sockaddr *from, int *fromlen, int recvlen)
Definition: sock.c:419

◆ simple_server()

static VOID WINAPI simple_server ( server_params par)
static

Definition at line 607 of file sock.c.

609{
610 test_params *gen = par->general;
612 int pos, n_recvd, n_sent, n_expected = gen->n_chunks * gen->chunk_size, tmp, i,
613 id = GetCurrentThreadId();
614
615 trace ( "simple_server (%x) starting\n", id );
616
617 set_so_opentype ( FALSE ); /* non-overlapped */
618 server_start ( par );
619 mem = TlsGetValue ( tls );
620
621 wsa_ok ( set_blocking ( mem->s, TRUE ), 0 ==, "simple_server (%x): failed to set blocking mode: %d\n");
622 wsa_ok ( listen ( mem->s, SOMAXCONN ), 0 ==, "simple_server (%x): listen failed: %d\n");
623
624 trace ( "simple_server (%x) ready\n", id );
625 SetEvent ( server_ready ); /* notify clients */
626
627 for ( i = 0; i < min ( gen->n_clients, MAX_CLIENTS ); i++ )
628 {
629 trace ( "simple_server (%x): waiting for client\n", id );
630
631 /* accept a single connection */
632 tmp = sizeof ( mem->sock[0].peer );
633 mem->sock[0].s = accept ( mem->s, (struct sockaddr*) &mem->sock[0].peer, &tmp );
634 wsa_ok ( mem->sock[0].s, INVALID_SOCKET !=, "simple_server (%x): accept failed: %d\n" );
635
636 ok ( mem->sock[0].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ),
637 "simple_server (%x): strange peer address\n", id );
638
639 /* Receive data & check it */
640 n_recvd = do_synchronous_recv ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
641 ok ( n_recvd == n_expected,
642 "simple_server (%x): received less data than expected: %d of %d\n", id, n_recvd, n_expected );
643 pos = test_buffer ( mem->sock[0].buf, gen->chunk_size, gen->n_chunks );
644 ok ( pos == -1, "simple_server (%x): test pattern error: %d\n", id, pos);
645
646 /* Echo data back */
647 n_sent = do_synchronous_send ( mem->sock[0].s, mem->sock[0].buf, n_expected, 0, par->buflen );
648 ok ( n_sent == n_expected,
649 "simple_server (%x): sent less data than expected: %d of %d\n", id, n_sent, n_expected );
650
651 /* cleanup */
652 read_zero_bytes ( mem->sock[0].s );
653 wsa_ok ( closesocket ( mem->sock[0].s ), 0 ==, "simple_server (%x): closesocket error: %d\n" );
654 mem->sock[0].s = INVALID_SOCKET;
655 }
656
657 trace ( "simple_server (%x) exiting\n", id );
658 server_stop ();

◆ START_TEST()

START_TEST ( sock  )

Definition at line 11756 of file sock.c.

11759{
11760 int i;
11761
11762/* Leave these tests at the beginning. They depend on WSAStartup not having been
11763 * called, which is done by Init() below. */
11766
11767 Init();
11768
11775
11776 for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
11777 {
11778 trace ( " **** STARTING TEST %d ****\n", i );
11779 do_test ( &tests[i] );
11780 trace ( " **** TEST %d COMPLETE ****\n", i );
11781 }
11782
11783 test_UDP();
11784
11789
11792
11795
11796 test_errors();
11797 test_listen();
11798 test_select();
11799 test_accept();
11805 test_dns();
11809
11812 test_WSARecv();
11813 test_WSAPoll();
11815 test_iocp();
11816
11817 test_events(0);
11818 test_events(1);
11819
11820 test_ipv6only();
11825
11826#ifdef __REACTOS__
11828 {
11829 skip("WSPAcceptEx(), WSPConnectEx() and WSPDisconnectEx() are UNIMPLEMENTED on ReactOS\n");
11830 skip("Skipping tests due to hang. See ROSTESTS-385\n");
11831 }
11832 else
11833 {
11834#endif
11835 test_AcceptEx();
11838#ifdef __REACTOS__
11839 }
11840#endif
11841
11844
11848
11851
11854
11855 /* this is an io heavy test, do it at the end so the kernel doesn't start dropping packets */
11856 test_send();
11858
static void do_test(void)
Definition: ftrandom.c:516
static void test_events(void)
Definition: itemdlg.c:1172
int winetest_interactive
static void test_WSAAddressToStringW(void)
Definition: sock.c:3191
static void test_WithWSAStartup(void)
Definition: sock.c:1185
static void test_WSAAsyncGetServByName(void)
Definition: sock.c:9776
static void test_send(void)
Definition: sock.c:5547
static void test_WSAStringToAddressA(void)
Definition: sock.c:3359
static void test_UDP(void)
Definition: sock.c:2299
static void test_GetAddrInfoExW(void)
Definition: sock.c:7815
static void test_inet_pton(void)
Definition: sock.c:5003
static void test_getpeername(void)
Definition: sock.c:9289
static void test_write_watch(void)
Definition: sock.c:7164
static void test_gethostbyname_hack(void)
Definition: sock.c:4774
static void test_WSADuplicateSocket(void)
Definition: sock.c:2795
static void test_TransmitFile(void)
Definition: sock.c:9056
static void test_WSAStringToAddressW(void)
Definition: sock.c:3483
static void test_ipv6only(void)
Definition: sock.c:6540
static void test_GetAddrInfoW(void)
Definition: sock.c:7534
static void Init(void)
Definition: sock.c:1287
static void test_synchronous_WSAIoctl(void)
Definition: sock.c:9663
static void test_inet_ntoa(void)
Definition: sock.c:10760
static void test_dns(void)
Definition: sock.c:4621
static void test_WSAEnumNetworkEvents(void)
Definition: sock.c:2956
static void test_completion_port(void)
Definition: sock.c:9859
static void test_gethostbyname(void)
Definition: sock.c:4677
static void test_listen(void)
Definition: sock.c:3693
static void test_WithoutWSAStartup(void)
Definition: sock.c:1170
static void test_so_reuseaddr(void)
Definition: sock.c:1924
static void test_getsockname(void)
Definition: sock.c:4530
static void test_WSAPoll(void)
Definition: sock.c:7324
static void test_WSAEnumNameSpaceProvidersW(void)
Definition: sock.c:11034
static void test_select(void)
Definition: sock.c:3780
static void test_accept(void)
Definition: sock.c:4251
static void test_inet_addr(void)
Definition: sock.c:4864
static void test_iocp(void)
Definition: sock.c:11719
static void test_DisconnectEx(void)
Definition: sock.c:8934
static void test_WSAEnumNameSpaceProvidersA(void)
Definition: sock.c:10949
static void test_WSARecv(void)
Definition: sock.c:6938
static void test_WSASocket(void)
Definition: sock.c:2409
static void test_ioctlsocket(void)
Definition: sock.c:5341
static void test_set_getsockopt(void)
Definition: sock.c:1408
static void test_WSAAddressToStringA(void)
Definition: sock.c:3029
static void test_WSALookupService(void)
Definition: sock.c:10788
static void test_ip_pktinfo(void)
Definition: sock.c:2003
static test_setup tests[]
Definition: sock.c:2190
static void test_errors(void)
Definition: sock.c:3656
static void test_sioAddressListChange(void)
Definition: sock.c:9427
static void test_getaddrinfo(void)
Definition: sock.c:7930
static void test_WSASendTo(void)
Definition: sock.c:6874
static void test_AcceptEx(void)
Definition: sock.c:8426
static void test_getservbyname(void)
Definition: sock.c:2388
static void test_gethostname(void)
Definition: sock.c:4831
static void test_extendedSocketOptions(void)
Definition: sock.c:4413
static void test_addr_to_print(void)
Definition: sock.c:4872
static void test_ConnectEx(void)
Definition: sock.c:8215
static void test_address_list_query(void)
Definition: sock.c:10686
static void test_WSASendMsg(void)
Definition: sock.c:6689
static void test_WSAAsyncGetServByPort(void)
Definition: sock.c:9746
static void test_sioRoutingInterfaceQuery(void)
Definition: sock.c:9379

◆ StartClients()

static void StartClients ( LPTHREAD_START_ROUTINE  routine,
test_params general,
client_params par 
)
static

Definition at line 1347 of file sock.c.

1350{
1351 int i;
1352 par->general = general;
1353 for ( i = 1; i <= min ( general->n_clients, MAX_CLIENTS ); i++ )
1354 {
1355 client_id = i - 1;
1356 thread[i] = CreateThread ( NULL, 0, routine, par, 0, &thread_id[i] );
1357 ok ( thread[i] != NULL, "Failed to create client thread\n" );
1358 /* Make sure the client is up and running */
1360 };
int jpeg_marker_parser_method routine
Definition: jpeglib.h:1093

Referenced by do_test().

◆ StartServer()

static void StartServer ( LPTHREAD_START_ROUTINE  routine,
test_params general,
server_params par 
)
static

Definition at line 1339 of file sock.c.

1342{
1343 par->general = general;
1344 thread[0] = CreateThread ( NULL, 0, routine, par, 0, &thread_id[0] );
1345 ok ( thread[0] != NULL, "Failed to create server thread\n" );

Referenced by do_test().

◆ sync_read()

static void sync_read ( SOCKET  src,
SOCKET  dst 
)
static

Definition at line 11119 of file sock.c.

11122{
11123 int ret;
11124 char data[512];
11125
11126 ret = send(dst, "Hello World!", 12, 0);
11127 ok(ret == 12, "send returned %d\n", ret);
11128
11129 memset(data, 0, sizeof(data));
11130 ret = recv(src, data, sizeof(data), 0);
11131 ok(ret == 12, "expected 12, got %d\n", ret);

◆ tcp_socketpair()

static int tcp_socketpair ( SOCKET src,
SOCKET dst 
)
static

Definition at line 241 of file sock.c.

243{
245 struct sockaddr_in addr;
246 int len;
247 int ret;
248
251
253 if (*src == INVALID_SOCKET)
254 goto end;
255
257 if (server == INVALID_SOCKET)
258 goto end;
259
260 memset(&addr, 0, sizeof(addr));
261 addr.sin_family = AF_INET;
262 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
263 ret = bind(server, (struct sockaddr*)&addr, sizeof(addr));
264 if (ret != 0)
265 goto end;
266
267 len = sizeof(addr);
268 ret = getsockname(server, (struct sockaddr*)&addr, &len);
269 if (ret != 0)
270 goto end;
271
272 ret = listen(server, 1);
273 if (ret != 0)
274 goto end;
275
276 ret = connect(*src, (struct sockaddr*)&addr, sizeof(addr));
277 if (ret != 0)
278 goto end;
279
280 len = sizeof(addr);
281 *dst = accept(server, (struct sockaddr*)&addr, &len);
282
283end:
284 if (server != INVALID_SOCKET)
286 if (*src != INVALID_SOCKET && *dst != INVALID_SOCKET)
287 return 0;
290 return -1;
#define IPPROTO_TCP
Definition: ip.h:196
static rfbScreenInfoPtr server
Definition: vnc.c:74

Referenced by test_select(), and test_WithWSAStartup().

◆ tcp_socketpair_ovl()

static int tcp_socketpair_ovl ( SOCKET src,
SOCKET dst 
)
static

Definition at line 292 of file sock.c.

294{
296 struct sockaddr_in addr;
297 int len, ret;
298
301
303 if (*src == INVALID_SOCKET)
304 goto end;
305
307 if (server == INVALID_SOCKET)
308 goto end;
309
310 memset(&addr, 0, sizeof(addr));
311 addr.sin_family = AF_INET;
312 addr.sin_addr.s_addr = inet_addr("127.0.0.1");
313 ret = bind(server, (struct sockaddr *)&addr, sizeof(addr));
314 if (ret != 0)
315 goto end;
316
317 len = sizeof(addr);
318 ret = getsockname(server, (struct sockaddr *)&addr, &len);
319 if (ret != 0)
320 goto end;
321
322 ret = listen(server, 1);
323 if (ret != 0)
324 goto end;
325
326 ret = connect(*src, (struct sockaddr *)&addr, sizeof(addr));
327 if (ret != 0)
328 goto end;
329
330 len = sizeof(addr);
331 *dst = accept(server, (struct sockaddr *)&addr, &len);
332
333end:
334 if (server != INVALID_SOCKET)
336 if (*src != INVALID_SOCKET && *dst != INVALID_SOCKET)
337 return 0;
340 return -1;
SOCKET WSAAPI WSASocketW(IN INT af, IN INT type, IN INT protocol, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, IN GROUP g, IN DWORD dwFlags)
Definition: socklife.c:490
#define WSA_FLAG_OVERLAPPED
Definition: winsock2.h:466

◆ test_accept()

static void test_accept ( void  )
static

Definition at line 4251 of file sock.c.

4254{
4255 int ret;
4257 struct sockaddr_in address;
4258 SOCKADDR_STORAGE ss, ss_empty;
4259 int socklen;
4260 select_thread_params thread_params;
4261 HANDLE thread_handle = NULL;
4262 DWORD id;
4263
4264 memset(&address, 0, sizeof(address));
4265 address.sin_addr.s_addr = inet_addr("127.0.0.1");
4266 address.sin_family = AF_INET;
4267
4268 socklen = sizeof(address);
4271 {
4272 trace("error creating server socket: %d\n", WSAGetLastError());
4273 return;
4274 }
4275
4276 connector = setup_connector_socket(&address, socklen, FALSE);
4277 if (connector == INVALID_SOCKET) goto done;
4278
4279 trace("Blocking accept next\n");
4280
4282 ok(accepted == INVALID_SOCKET && WSAGetLastError() == WSATRY_AGAIN, "Failed to defer connection, %d\n", WSAGetLastError());
4283
4285 ok(accepted != INVALID_SOCKET, "Failed to accept deferred connection, error %d\n", WSAGetLastError());
4286