ReactOS 0.4.15-dev-7968-g24a56f8
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}
Definition: _set.h:50
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLdouble s
Definition: gl.h:2039
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
int32_t INT
Definition: typedefs.h:58

◆ 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;
52
53 DPRINT("select: %lx %p %p %p %p\n", s, readfds, writefds, exceptfds, timeout);
54
55 /* Check for WSAStartup */
57
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 NO_ERROR
Definition: dderror.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:752
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
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define DPRINT
Definition: sndvol32.h:71
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
LPWSPSELECT lpWSPSelect
Definition: ws2spi.h:483
PTPROVIDER Provider
Definition: ws2_32p.h:199
Definition: dhcpd.h:245
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
#define WSAEINVAL
Definition: winerror.h:1946
#define WSAENOTSOCK
Definition: winerror.h:1951
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCKET_ERROR
Definition: winsock.h:333
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
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

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(), LISTVIEW_HitTest(), main(), mark_patched_components(), NetBTWaitForNameResponse(), netconn_create(), processRequest(), rdp2vnc_connect(), read_vc(), ReceiveData(), ReceiveLine(), rtime(), runProg(), SAcceptS(), SClose(), SConnect(), select_server(), SelectR(), SelectW(), CHttpClient::SendFile(), ServiceMain(), SRead(), SRecv(), SRecvfrom(), SSend(), SSendto(), SSendtoByName(), START_TEST(), svc_run(), SWaitUntilReadyForReading(), SWaitUntilReadyForWriting(), SWrite(), test_elems(), 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(), and WaitResponse().

◆ 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:115

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;
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}
HWND hWnd
Definition: settings.c:17
LPWSPASYNCSELECT lpWSPAsyncSelect
Definition: ws2spi.h:463
HANDLE lEvent
Definition: tftpd.cpp:56

Referenced by InternetTransport_ReadLine(), InternetTransport_WndProc(), mi_create_window(), and test_events().

◆ 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;
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}
LPWSPEVENTSELECT lpWSPEventSelect
Definition: ws2spi.h:471

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(), and test_events().