ReactOS  0.4.14-dev-608-gd495a4f
send.c File Reference
#include <ws2_32.h>
#include <debug.h>
Include dependency graph for send.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

INT WSAAPI send (IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
 
INT WSAAPI sendto (IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
 
INT WSAAPI WSASend (IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
INT WSAAPI WSASendDisconnect (IN SOCKET s, IN LPWSABUF lpOutboundDisconnectData)
 
INT WSAAPI WSASendTo (IN SOCKET s, IN LPWSABUF lpBuffers, IN DWORD dwBufferCount, OUT LPDWORD lpNumberOfBytesSent, IN DWORD dwFlags, IN CONST struct sockaddr *lpTo, IN INT iToLen, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file send.c.

Function Documentation

◆ send()

INT WSAAPI send ( IN SOCKET  s,
IN CONST CHAR FAR buf,
IN INT  len,
IN INT  flags 
)

Definition at line 23 of file send.c.

27 {
28  PWSSOCKET Socket;
29  INT Status;
30  INT ErrorCode;
31  LPWSATHREADID ThreadId;
33  DWORD BytesSent;
34  DPRINT("sendto: %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 = (PCHAR)buf;
44  Buffers.len = len;
45 
46  /* Make the call */
47  Status = Socket->Provider->Service.lpWSPSend(s,
48  &Buffers,
49  1,
50  &BytesSent,
51  (DWORD)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) return BytesSent;
61 
62  /* If everything seemed fine, then the WSP call failed itself */
64  }
65  else
66  {
67  /* No Socket Context Found */
69  }
70  }
71 
72  /* Return with an Error */
74  return SOCKET_ERROR;
75 }
#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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
PVOID Buffers[0x100]
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
#define PCHAR
Definition: match.c:90
PTPROVIDER Provider
Definition: ws2_32p.h:199
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
LPWSPSEND lpWSPSend
Definition: ws2spi.h:484

Referenced by adns_writev(), do_synchronous_send(), DoTelnetHandshake(), EchoIncomingPackets(), event_client(), fprintfSocket(), fputcSocket(), fputSocket(), fputsSocket(), GetRequestAndWait(), InternetTransport_Write(), iocp_async_read(), iocp_async_read_thread(), main(), NETCON_set_timeout(), netconn_set_timeout(), netfinger(), RequestHandler::OkToSend(), processRequest(), proxtrans(), push_dochost_task(), read_data(), read_pipe(), ReadFromPipeThread(), ReceiveLine(), recvrequest(), rpcrt4_conn_tcp_write(), SConnect(), select_server(), send_buf(), send_subvol(), SendLine(), SendQuote(), sendrequest(), SendTelnetInterrupt(), SendTime(), server_send_reply(), server_send_string(), server_thread(), sock_send(), SSend(), START_TEST(), Mapdesc::subdivide(), SWrite(), sync_read(), tcp_send(), test_AcceptEx(), test_communication(), test_completion_port(), test_events(), test_ioctlsocket(), test_select(), test_send(), test_TransmitFile(), test_WithWSAStartup(), test_write_watch(), test_WSAPoll(), test_WSARecv(), CServerClientSocket::Transmit(), uninit(), UserLoginThread(), WinHttpSetTimeouts(), write_vc(), TNetwork::WriteString(), and WriteToPipeThread().

◆ sendto()

INT WSAAPI sendto ( IN SOCKET  s,
IN CONST CHAR FAR buf,
IN INT  len,
IN INT  flags,
IN CONST struct sockaddr to,
IN INT  tolen 
)

Definition at line 82 of file send.c.

88 {
89  PWSSOCKET Socket;
90  INT Status;
91  INT ErrorCode;
92  LPWSATHREADID ThreadId;
94  DWORD BytesSent;
95  DPRINT("sendto: %lx, %lx, %lx, %p\n", s, flags, len, buf);
96 
97  /* Check for WSAStartup */
98  if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
99  {
100  /* Get the Socket Context */
101  if ((Socket = WsSockGetSocket(s)))
102  {
103  /* Setup the buffers */
104  Buffers.buf = (PCHAR)buf;
105  Buffers.len = len;
106 
107  /* Make the call */
108  Status = Socket->Provider->Service.lpWSPSendTo(s,
109  &Buffers,
110  1,
111  &BytesSent,
112  (DWORD)flags,
113  to,
114  tolen,
115  NULL,
116  NULL,
117  ThreadId,
118  &ErrorCode);
119  /* Deference the Socket Context */
120  WsSockDereference(Socket);
121 
122  /* Return Provider Value */
123  if (Status == ERROR_SUCCESS) return BytesSent;
124 
125  /* If everything seemed fine, then the WSP call failed itself */
127  }
128  else
129  {
130  /* No Socket Context Found */
132  }
133  }
134 
135  /* Return with an Error */
137  return SOCKET_ERROR;
138 }
#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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
PVOID Buffers[0x100]
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
#define PCHAR
Definition: match.c:90
PTPROVIDER Provider
Definition: ws2_32p.h:199
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
LPWSPSENDTO lpWSPSendTo
Definition: ws2spi.h:486
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994

Referenced by __rpc_get_time_offset(), adns__query_send(), IcmpSendEcho(), main(), processRequest(), rpc_broadcast_exp(), rtime(), send_packet(), SendData(), SendRequest(), Sendto(), SendtoByName(), SSendto(), SSendtoByName(), svc_dg_recv(), svc_dg_reply(), Test_CloseDuplicatedSocket(), test_getpeername(), test_ip_pktinfo(), test_sendto(), test_UDP(), test_WSADuplicateSocket(), vsyslog(), and write_packet().

◆ WSASend()

INT WSAAPI WSASend ( IN SOCKET  s,
IN LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesSent,
IN DWORD  dwFlags,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 145 of file send.c.

152 {
153  PWSSOCKET Socket;
154  INT Status;
155  INT ErrorCode;
156  LPWSATHREADID ThreadId;
157  DPRINT("WSARecvFrom: %lx, %lx, %lx, %p\n", s, dwFlags, dwBufferCount, lpBuffers);
158 
159  /* Check for WSAStartup */
160  if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
161  {
162  /* Get the Socket Context */
163  if ((Socket = WsSockGetSocket(s)))
164  {
165  /* Make the call */
166  Status = Socket->Provider->Service.lpWSPSend(s,
167  lpBuffers,
168  dwBufferCount,
169  lpNumberOfBytesSent,
170  dwFlags,
171  lpOverlapped,
172  lpCompletionRoutine,
173  ThreadId,
174  &ErrorCode);
175  /* Deference the Socket Context */
176  WsSockDereference(Socket);
177 
178  /* Return Provider Value */
179  if (Status == ERROR_SUCCESS) return Status;
180 
181  /* If everything seemed fine, then the WSP call failed itself */
183  }
184  else
185  {
186  /* No Socket Context Found */
188  }
189  }
190 
191  /* Return with an Error */
193  return SOCKET_ERROR;
194 }
#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
#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
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
LPWSPSEND lpWSPSend
Definition: ws2spi.h:484

Referenced by NetBTSend(), NetBTSessionReq(), test_completion_port(), test_send(), and Test_WSARecv().

◆ WSASendDisconnect()

INT WSAAPI WSASendDisconnect ( IN SOCKET  s,
IN LPWSABUF  lpOutboundDisconnectData 
)

Definition at line 201 of file send.c.

203 {
206  PWSSOCKET Socket;
207  INT ErrorCode;
208  INT Status;
209  DPRINT("WSASendDisconnect: %lx %p\n", s, lpOutboundDisconnectData);
210 
211  /* Enter prolog */
213  {
214  /* Get the Socket Context */
215  if ((Socket = WsSockGetSocket(s)))
216  {
217  /* Make the call */
219  lpOutboundDisconnectData,
220  &ErrorCode);
221  /* Deference the Socket Context */
222  WsSockDereference(Socket);
223 
224  /* Return Provider Value */
225  if (Status == ERROR_SUCCESS) return ERROR_SUCCESS;
226 
227  /* If everything seemed fine, then the WSP call failed itself */
229  }
230  else
231  {
232  /* No Socket Context Found */
234  }
235  }
236 
237  /* Return with an Error */
239  return SOCKET_ERROR;
240 }
#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
#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
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SetLastError(x)
Definition: compat.h:417
INT WSAAPI WsApiProlog(OUT PWSPROCESS *Process, OUT PWSTHREAD *Thread)
Definition: wsautil.c:91
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
LPWSPSENDDISCONNECT lpWSPSendDisconnect
Definition: ws2spi.h:485
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ WSASendTo()

INT WSAAPI WSASendTo ( IN SOCKET  s,
IN LPWSABUF  lpBuffers,
IN DWORD  dwBufferCount,
OUT LPDWORD  lpNumberOfBytesSent,
IN DWORD  dwFlags,
IN CONST struct sockaddr lpTo,
IN INT  iToLen,
IN LPWSAOVERLAPPED  lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 247 of file send.c.

256 {
257  PWSSOCKET Socket;
258  INT Status;
259  INT ErrorCode;
260  LPWSATHREADID ThreadId;
261  DPRINT("WSASendTo: %lx, %lx, %lx, %p\n", s, dwFlags, dwBufferCount, lpBuffers);
262 
263  /* Check for WSAStartup */
264  if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
265  {
266  /* Get the Socket Context */
267  if ((Socket = WsSockGetSocket(s)))
268  {
269  /* Make the call */
270  Status = Socket->Provider->Service.lpWSPSendTo(s,
271  lpBuffers,
272  dwBufferCount,
273  lpNumberOfBytesSent,
274  dwFlags,
275  lpTo,
276  iToLen,
277  lpOverlapped,
278  lpCompletionRoutine,
279  ThreadId,
280  &ErrorCode);
281  /* Deference the Socket Context */
282  WsSockDereference(Socket);
283 
284  /* Return Provider Value */
285  if (Status == ERROR_SUCCESS) return Status;
286 
287  /* If everything seemed fine, then the WSP call failed itself */
289  }
290  else
291  {
292  /* No Socket Context Found */
294  }
295  }
296 
297  /* Return with an Error */
299  return SOCKET_ERROR;
300 }
#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
#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
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
PTPROVIDER Provider
Definition: ws2_32p.h:199
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLdouble s
Definition: gl.h:2039
LPWSPSENDTO lpWSPSendTo
Definition: ws2spi.h:486
Status
Definition: gdiplustypes.h:24
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90

Referenced by NetBTSendNameQuery(), and test_WSASendTo().