ReactOS  0.4.13-dev-455-g28ed234
select.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for select.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

INT WSPAPI __WSAFDIsSet (SOCKET s, LPFD_SET set)
 
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)
 
INT WSPAPI WPUFDIsSet (IN SOCKET s, IN LPFD_SET set)
 
INT WSAAPI WSAAsyncSelect (IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent)
 
INT WSAAPI WSAEventSelect (IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file select.c.

Function Documentation

◆ __WSAFDIsSet()

INT WSPAPI __WSAFDIsSet ( SOCKET  s,
LPFD_SET  set 
)

Definition at line 23 of file select.c.

25 {
26  INT i = set->fd_count;
27  INT Return = FALSE;
28 
29  /* Loop until a match is found */
30  while (i--) if (set->fd_array[i] == s) Return = TRUE;
31 
32  /* Return */
33  return Return;
34 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
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
GLdouble s
Definition: gl.h:2039
Definition: _set.h:46

◆ select()

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 at line 41 of file select.c.

46 {
47  PWSSOCKET Socket;
48  INT Status;
49  INT ErrorCode;
50  SOCKET Handle;
52 
53  DPRINT("select: %lx %p %p %p %p\n", s, readfds, writefds, exceptfds, timeout);
54 
55  /* Check for WSAStartup */
57 
58  if (ErrorCode != ERROR_SUCCESS)
59  {
61  return SOCKET_ERROR;
62  }
63 
64  /* Use the first Socket from the first valid set */
65  if (readfds && readfds->fd_count)
66  {
67  Handle = readfds->fd_array[0];
68  }
69  else if (writefds && writefds->fd_count)
70  {
71  Handle = writefds->fd_array[0];
72  }
73  else if (exceptfds && exceptfds->fd_count)
74  {
75  Handle = exceptfds->fd_array[0];
76  }
77  else
78  {
79  /* Invalid handles */
81  return SOCKET_ERROR;
82  }
83 
84  /* Get the Socket Context */
85  Socket = WsSockGetSocket(Handle);
86 
87  if (!Socket)
88  {
89  /* No Socket Context Found */
91  return SOCKET_ERROR;
92  }
93 
94  /* Get the select procedure */
96 
97  /* Make the call */
98  Status = WSPSelect(s, readfds, writefds, exceptfds, (struct timeval *)timeout,
99  &ErrorCode);
100 
101  /* Deference the Socket Context */
102  WsSockDereference(Socket);
103 
104  /* Return Provider Value */
105  if (Status != SOCKET_ERROR)
106  return Status;
107 
108  /* If everything seemed fine, then the WSP call failed itself */
109  if (ErrorCode == NO_ERROR)
111 
112  /* Return with an error */
114  return SOCKET_ERROR;
115 }
#define WSAENOTSOCK
Definition: winerror.h:1951
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WSAEINVAL
Definition: winerror.h:1946
int(WSPAPI * LPWSPSELECT)(_In_ int nfds, _Inout_opt_ fd_set FAR *readfds, _Inout_opt_ fd_set FAR *writefds, _Inout_opt_ fd_set FAR *exceptfds, _In_opt_ const struct timeval FAR *timeout, _Out_ LPINT lpErrno)
Definition: ws2spi.h:244
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
Definition: dhcpd.h:245
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
LPWSPSELECT lpWSPSelect
Definition: ws2spi.h:483
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
void DPRINT(...)
Definition: polytest.cpp:61
_In_ HANDLE Handle
Definition: extypes.h:390
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:409
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
int WSPAPI WSPSelect(IN int nfds, IN OUT fd_set *readfds OPTIONAL, IN OUT fd_set *writefds OPTIONAL, IN OUT fd_set *exceptfds OPTIONAL, IN const struct timeval *timeout OPTIONAL, OUT LPINT lpErrno)
Definition: dllmain.c:1065
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
UINT_PTR SOCKET
Definition: winsock.h:47
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892

Referenced by __rpc_get_time_offset(), _get_select_iface(), _test_select_get_disabled(), _test_select_length(), _test_select_multiple(), _test_select_name(), _test_select_put_length(), _test_select_put_selidx(), _test_select_selidx(), _test_select_set_disabled(), _test_select_set_multiple(), _test_select_set_name(), _test_select_set_size(), _test_select_set_value(), _test_select_size(), _test_select_type(), _test_select_value(), AcceptConnections(), add_store_certs(), adns_wait(), check_sck(), checkRecv(), create_netconn_socket(), DATETIME_SetSelectedField(), DoTelnetHandshake(), drain_socket_thread(), empty(), FTP_GetNextLine(), GetRequestAndWait(), IcmpSendEcho(), LISTVIEW_HitTest(), main(), msi_add_records_to_table(), msi_dialog_seltree_handler(), NetBTWaitForNameResponse(), netconn_create(), processRequest(), rdp2vnc_connect(), read_vc(), ReceiveData(), ReceiveLine(), rtime(), runProg(), SAcceptS(), SClose(), SConnect(), select_server(), SelectR(), SelectReadThread(), SelectW(), CHttpClient::SendFile(), ServiceMain(), SRead(), SRecv(), SRecvfrom(), SSend(), SSendto(), SSendtoByName(), START_TEST(), svc_run(), SWaitUntilReadyForReading(), SWaitUntilReadyForWriting(), SWrite(), test_AcceptEx(), test_completion_port(), test_elems(), test_errors(), test_select(), test_select_elem(), test_select_form(), test_select_form_notfound(), test_select_remove(), test_TVS_SINGLEEXPAND(), Test_WSARecv(), thread_proc(), ui_select(), WaitForRemoteInput(), WaitForRemoteOutput(), WaitResponse(), and yyparse().

◆ WPUFDIsSet()

INT WSPAPI WPUFDIsSet ( IN SOCKET  s,
IN LPFD_SET  set 
)

Definition at line 122 of file select.c.

124 {
126  return (SOCKET)0;
127 }
#define UNIMPLEMENTED
Definition: debug.h:114
UINT_PTR SOCKET
Definition: winsock.h:47

Referenced by WsTpInitialize().

◆ WSAAsyncSelect()

INT WSAAPI WSAAsyncSelect ( IN SOCKET  s,
IN HWND  hWnd,
IN UINT  wMsg,
IN LONG  lEvent 
)

Definition at line 134 of file select.c.

138 {
139  PWSSOCKET Socket;
140  INT Status;
141  INT ErrorCode;
142  DPRINT("WSAAsyncSelect: %lx, %lx, %lx, %lx\n", s, hWnd, wMsg, lEvent);
143 
144  /* Check for WSAStartup */
146  {
147  /* Get the Socket Context */
148  if ((Socket = WsSockGetSocket(s)))
149  {
150  /* Make the call */
152  hWnd,
153  wMsg,
154  lEvent,
155  &ErrorCode);
156  /* Deference the Socket Context */
157  WsSockDereference(Socket);
158 
159  /* Return Provider Value */
160  if (Status == ERROR_SUCCESS) return Status;
161 
162  /* If everything seemed fine, then the WSP call failed itself */
164  }
165  else
166  {
167  /* No Socket Context Found */
169  }
170  }
171 
172  /* Return with an Error */
174  return SOCKET_ERROR;
175 }
#define WSAENOTSOCK
Definition: winerror.h:1951
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSPASYNCSELECT lpWSPAsyncSelect
Definition: ws2spi.h:463
HWND hWnd
Definition: settings.c:17
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
void DPRINT(...)
Definition: polytest.cpp:61
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:409
HANDLE lEvent
Definition: tftpd.cpp:56
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892

Referenced by InternetTransport_ReadLine(), InternetTransport_WndProc(), iocp_async_closesocket(), iocp_async_read_closesocket(), mi_create_window(), test_events(), and wsa_async_select_thread().

◆ WSAEventSelect()

INT WSAAPI WSAEventSelect ( IN SOCKET  s,
IN WSAEVENT  hEventObject,
IN LONG  lNetworkEvents 
)

Definition at line 182 of file select.c.

185 {
186  PWSSOCKET Socket;
187  INT Status;
188  INT ErrorCode;
189 
190  /* Check for WSAStartup */
192  {
193  /* Get the Socket Context */
194  if ((Socket = WsSockGetSocket(s)))
195  {
196  /* Make the call */
198  hEventObject,
199  lNetworkEvents,
200  &ErrorCode);
201  /* Deference the Socket Context */
202  WsSockDereference(Socket);
203 
204  /* Return Provider Value */
205  if (Status == ERROR_SUCCESS) return Status;
206  }
207  else
208  {
209  /* No Socket Context Found */
211  }
212  }
213 
214  /* Return with an Error */
216  return SOCKET_ERROR;
217 }
#define WSAENOTSOCK
Definition: winerror.h:1951
#define SOCKET_ERROR
Definition: winsock.h:333
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
LPWSPEVENTSELECT lpWSPEventSelect
Definition: ws2spi.h:471
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:409
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892

Referenced by CServerSocket::Close(), dispatch(), event_client(), rpcrt4_protseq_sock_get_wait_array(), rpcrt4_sock_wait_for_recv(), rpcrt4_sock_wait_for_send(), CSocket::SetEvents(), START_TEST(), test_events(), test_sioAddressListChange(), and test_WSAEnumNetworkEvents().