ReactOS 0.4.16-dev-91-g764881a
recv.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for recv.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

INT WSAAPI recv (IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
 
INT WSAAPI recvfrom (IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
 
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)
 
INT WSAAPI WSARecvDisconnect (IN SOCKET s, OUT LPWSABUF lpInboundDisconnectData)
 
INT WSAAPI WSARecvFrom (IN SOCKET s, IN OUT LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesRecvd, IN OUT LPDWORD lpFlags, OUT LPSOCKADDR lpFrom, IN OUT LPINT lpFromlen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file recv.c.

Function Documentation

◆ recv()

INT WSAAPI recv ( IN SOCKET  s,
OUT CHAR FAR buf,
IN INT  len,
IN INT  flags 
)

Definition at line 23 of file recv.c.

27{
28 PWSSOCKET Socket;
29 INT Status;
31 LPWSATHREADID ThreadId;
33 DWORD BytesReceived;
34 DPRINT("recv: %lx, %lx, %lx, %p\n", s, flags, len, buf);
35
36 /* Check for WSAStartup */
37 if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
38 {
39 /* Get the Socket Context */
40 if ((Socket = WsSockGetSocket(s)))
41 {
42 /* Setup the buffers */
43 Buffers.buf = buf;
44 Buffers.len = len;
45
46 /* Make the call */
48 &Buffers,
49 1,
50 &BytesReceived,
51 (LPDWORD)&flags,
52 NULL,
53 NULL,
54 ThreadId,
55 &ErrorCode);
56 /* Deference the Socket Context */
57 WsSockDereference(Socket);
58
59 /* Return Provider Value */
60 if (Status == ERROR_SUCCESS)
61 {
62 /* Handle OOB */
63 if (!(flags & MSG_PARTIAL)) return BytesReceived;
65 }
66
67 /* If everything seemed fine, then the WSP call failed itself */
69 }
70 else
71 {
72 /* No Socket Context Found */
74 }
75 }
76
77 /* Return with an Error */
79 return SOCKET_ERROR;
80}
PVOID Buffers[0x100]
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLdouble s
Definition: gl.h:2039
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define DPRINT
Definition: sndvol32.h:73
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
LPWSPRECV lpWSPRecv
Definition: ws2spi.h:480
PTPROVIDER Provider
Definition: ws2_32p.h:199
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
#define WSAENOTSOCK
Definition: winerror.h:1951
#define WSAEMSGSIZE
Definition: winerror.h:1953
#define SOCKET_ERROR
Definition: winsock.h:333
#define MSG_PARTIAL
Definition: winsock.h:402
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140

Referenced by __rpc_get_time_offset(), _server_read_data(), close_connection(), compare_file2(), do_synchronous_recv(), DoTelnetHandshake(), drain_socket_thread(), EchoIncomingPackets(), event_client(), fgetcSocket(), fgetsSocket(), InternetTransport_WndProc(), main(), netfinger(), processRequest(), read_line(), read_vc(), read_zero_bytes(), TNetwork::ReadString(), CServerClientSocket::Receive(), receive_data(), ReceiveIncomingPackets(), ReceiveLine(), recvrequest(), RecvSubvolGUIW(), rpcrt4_conn_tcp_read(), rtime(), WriterThread::Run(), select_server(), send_file(), server_read_data(), server_thread(), ShutdownConnection(), sock_recv(), SRead(), SRecv(), START_TEST(), tcp_recv(), test_events(), Test_ioctlsocket(), Test_Overread(), Test_recv(), and test_select().

◆ recvfrom()

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 at line 87 of file recv.c.

93{
94 PWSSOCKET Socket;
95 INT Status;
97 LPWSATHREADID ThreadId;
99 DWORD BytesReceived;
100 DPRINT("recvfrom: %lx, %lx, %lx, %p\n", s, flags, len, buf);
101
102 /* Check for WSAStartup */
103 if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
104 {
105 /* Get the Socket Context */
106 if ((Socket = WsSockGetSocket(s)))
107 {
108 /* Setup the buffers */
109 Buffers.buf = buf;
110 Buffers.len = len;
111
112 /* Make the call */
114 &Buffers,
115 1,
116 &BytesReceived,
117 (LPDWORD)&flags,
118 from,
119 fromlen,
120 NULL,
121 NULL,
122 ThreadId,
123 &ErrorCode);
124 /* Deference the Socket Context */
125 WsSockDereference(Socket);
126
127 /* Return Provider Value */
128 if (Status == ERROR_SUCCESS)
129 {
130 /* Handle OOB */
131 if (!(flags & MSG_PARTIAL)) return BytesReceived;
133 }
134
135 /* If everything seemed fine, then the WSP call failed itself */
137 }
138 else
139 {
140 /* No Socket Context Found */
142 }
143 }
144
145 /* Return with an Error */
147 return SOCKET_ERROR;
148}
CardRegion * from
Definition: spigame.cpp:19
LPWSPRECVFROM lpWSPRecvFrom
Definition: ws2spi.h:482

Referenced by __rpc_get_time_offset(), adns_processreadable(), do_synchronous_recvfrom(), main(), processRequest(), receive_packet(), ReceiveData(), rpc_broadcast_exp(), rtime(), SendRequest(), server_thread(), SRecvfrom(), and svc_dg_recv().

◆ WSARecv()

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 at line 155 of file recv.c.

162{
163 PWSSOCKET Socket;
164 INT Status;
166 LPWSATHREADID ThreadId;
167 DPRINT("WSARecv: %lx, %lx, %lx, %p\n", s, lpFlags, dwBufferCount, lpBuffers);
168
169 /* Check for WSAStartup */
170 if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
171 {
172 /* Get the Socket Context */
173 if ((Socket = WsSockGetSocket(s)))
174 {
175 /* Make the call */
176 Status = Socket->Provider->Service.lpWSPRecv(s,
177 lpBuffers,
178 dwBufferCount,
179 lpNumberOfBytesRecvd,
180 lpFlags,
182 lpCompletionRoutine,
183 ThreadId,
184 &ErrorCode);
185 /* Deference the Socket Context */
186 WsSockDereference(Socket);
187
188 /* Return Provider Value */
189 if (Status == ERROR_SUCCESS) return Status;
190
191 /* If everything seemed fine, then the WSP call failed itself */
193 }
194 else
195 {
196 /* No Socket Context Found */
198 }
199 }
200
201 /* Return with an Error */
203 return SOCKET_ERROR;
204}
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93

Referenced by NetBTRecv(), NetBTSessionReq(), test_events(), Test_Overread(), and Test_WSARecv().

◆ WSARecvDisconnect()

INT WSAAPI WSARecvDisconnect ( IN SOCKET  s,
OUT LPWSABUF  lpInboundDisconnectData 
)

Definition at line 211 of file recv.c.

213{
216 PWSSOCKET Socket;
218 INT Status;
219 DPRINT("WSARecvDisconnect: %lx %p\n", s, lpInboundDisconnectData);
220
221 /* Enter prolog */
223 {
224 /* Get the Socket Context */
225 if ((Socket = WsSockGetSocket(s)))
226 {
227 /* Make the call */
229 lpInboundDisconnectData,
230 &ErrorCode);
231 /* Deference the Socket Context */
232 WsSockDereference(Socket);
233
234 /* Return Provider Value */
235 if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
236 }
237 else
238 {
239 /* No Socket Context Found */
241 }
242 }
243
244 /* Return with an Error */
246 return SOCKET_ERROR;
247}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
LPWSPRECVDISCONNECT lpWSPRecvDisconnect
Definition: ws2spi.h:481
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91

◆ WSARecvFrom()

INT WSAAPI WSARecvFrom ( IN SOCKET  s,
IN OUT LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesRecvd,
IN OUT LPDWORD  lpFlags,
OUT LPSOCKADDR  lpFrom,
IN OUT LPINT  lpFromlen,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 254 of file recv.c.

263{
264 PWSSOCKET Socket;
265 INT Status;
267 LPWSATHREADID ThreadId;
268 DPRINT("WSARecvFrom: %lx, %lx, %lx, %p\n", s, lpFlags, dwBufferCount, lpBuffers);
269
270 /* Check for WSAStartup */
271 if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
272 {
273 /* Get the Socket Context */
274 if ((Socket = WsSockGetSocket(s)))
275 {
276 /* Make the call */
278 lpBuffers,
279 dwBufferCount,
280 lpNumberOfBytesRecvd,
281 lpFlags,
282 lpFrom,
283 lpFromlen,
285 lpCompletionRoutine,
286 ThreadId,
287 &ErrorCode);
288 /* Deference the Socket Context */
289 WsSockDereference(Socket);
290
291 /* Return Provider Value */
292 if (Status == ERROR_SUCCESS) return Status;
293
294 /* If everything seemed fine, then the WSP call failed itself */
296 }
297 else
298 {
299 /* No Socket Context Found */
301 }
302 }
303
304 /* Return with an Error */
306 return SOCKET_ERROR;
307}

Referenced by NetBTWaitForNameResponse().