8b4a30db1765f10c8e9e962afb423196874c60b4
[reactos.git] / reactos / lib / ws2_32 / misc / sndrcv.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 DLL
4 * FILE: misc/sndrcv.c
5 * PURPOSE: Send/receive functions
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/09-2000 Created
9 */
10 #include <ws2_32.h>
11 #include <catalog.h>
12
13 INT
14 EXPORT
15 recv(
16 IN SOCKET s,
17 OUT CHAR FAR* buf,
18 IN INT len,
19 IN INT flags)
20 {
21 UNIMPLEMENTED
22
23 return 0;
24 }
25
26
27 INT
28 EXPORT
29 recvfrom(
30 IN SOCKET s,
31 OUT CHAR FAR* buf,
32 IN INT len,
33 IN INT flags,
34 OUT LPSOCKADDR from,
35 IN OUT INT FAR* fromlen)
36 {
37 DWORD BytesReceived;
38 WSABUF WSABuf;
39
40 WS_DbgPrint(MAX_TRACE, ("s (0x%X) buf (0x%X) len (0x%X) flags (0x%X).\n",
41 s, buf, len, flags));
42
43 WSABuf.len = len;
44 WSABuf.buf = (CHAR FAR*)buf;
45
46 return WSARecvFrom(s, &WSABuf, 1, &BytesReceived, (LPDWORD)&flags, from, fromlen, NULL, NULL);
47 }
48
49
50 INT
51 EXPORT
52 send(
53 IN SOCKET s,
54 IN CONST CHAR FAR* buf,
55 IN INT len,
56 IN INT flags)
57 {
58 UNIMPLEMENTED
59
60 return 0;
61 }
62
63
64 INT
65 EXPORT
66 sendto(
67 IN SOCKET s,
68 IN CONST CHAR FAR* buf,
69 IN INT len,
70 IN INT flags,
71 IN CONST LPSOCKADDR to,
72 IN INT tolen)
73 {
74 DWORD BytesSent;
75 WSABUF WSABuf;
76
77 WS_DbgPrint(MAX_TRACE, ("s (0x%X) buf (0x%X) len (0x%X) flags (0x%X).\n",
78 s, buf, len, flags));
79
80 WSABuf.len = len;
81 WSABuf.buf = (CHAR FAR*)buf;
82
83 return WSASendTo(s, &WSABuf, 1, &BytesSent, flags, to, tolen, NULL, NULL);
84 }
85
86
87 INT
88 EXPORT
89 WSARecv(
90 IN SOCKET s,
91 IN OUT LPWSABUF lpBuffers,
92 IN DWORD dwBufferCount,
93 OUT LPDWORD lpNumberOfBytesRecvd,
94 IN OUT LPDWORD lpFlags,
95 IN LPWSAOVERLAPPED lpOverlapped,
96 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
97 {
98 UNIMPLEMENTED
99
100 return 0;
101 }
102
103
104 INT
105 EXPORT
106 WSARecvDisconnect(
107 IN SOCKET s,
108 OUT LPWSABUF lpInboundDisconnectData)
109 {
110 UNIMPLEMENTED
111
112 return 0;
113 }
114
115
116 INT
117 EXPORT
118 WSARecvFrom(
119 IN SOCKET s,
120 IN OUT LPWSABUF lpBuffers,
121 IN DWORD dwBufferCount,
122 OUT LPDWORD lpNumberOfBytesRecvd,
123 IN OUT LPDWORD lpFlags,
124 OUT LPSOCKADDR lpFrom,
125 IN OUT LPINT lpFromlen,
126 IN LPWSAOVERLAPPED lpOverlapped,
127 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
128 {
129 PCATALOG_ENTRY Provider;
130 INT Errno;
131 INT Code;
132
133 WS_DbgPrint(MAX_TRACE, ("Called.\n"));
134
135 if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) {
136 WSASetLastError(WSAENOTSOCK);
137 return SOCKET_ERROR;
138 }
139
140 assert(Provider->ProcTable.lpWSPRecvFrom);
141
142 Code = Provider->ProcTable.lpWSPRecvFrom(s, lpBuffers, dwBufferCount,
143 lpNumberOfBytesRecvd, lpFlags, lpFrom, lpFromlen, lpOverlapped,
144 lpCompletionRoutine, NULL /* lpThreadId */, &Errno);
145
146 DereferenceProviderByPointer(Provider);
147
148 if (Code == SOCKET_ERROR)
149 WSASetLastError(Errno);
150
151 return Code;
152 }
153
154
155 INT
156 EXPORT
157 WSASend(
158 IN SOCKET s,
159 IN LPWSABUF lpBuffers,
160 IN DWORD dwBufferCount,
161 OUT LPDWORD lpNumberOfBytesSent,
162 IN DWORD dwFlags,
163 IN LPWSAOVERLAPPED lpOverlapped,
164 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
165 {
166 UNIMPLEMENTED
167
168 return 0;
169 }
170
171
172 INT
173 EXPORT
174 WSASendDisconnect(
175 IN SOCKET s,
176 IN LPWSABUF lpOutboundDisconnectData)
177 {
178 UNIMPLEMENTED
179
180 return 0;
181 }
182
183
184 INT
185 EXPORT
186 WSASendTo(
187 IN SOCKET s,
188 IN LPWSABUF lpBuffers,
189 IN DWORD dwBufferCount,
190 OUT LPDWORD lpNumberOfBytesSent,
191 IN DWORD dwFlags,
192 IN CONST LPSOCKADDR lpTo,
193 IN INT iToLen,
194 IN LPWSAOVERLAPPED lpOverlapped,
195 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
196 {
197 PCATALOG_ENTRY Provider;
198 INT Errno;
199 INT Code;
200
201 WS_DbgPrint(MAX_TRACE, ("Called.\n"));
202
203 if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) {
204 WSASetLastError(WSAENOTSOCK);
205 return SOCKET_ERROR;
206 }
207
208 assert(Provider->ProcTable.lpWSPSendTo);
209
210 Code = Provider->ProcTable.lpWSPSendTo(s, lpBuffers, dwBufferCount,
211 lpNumberOfBytesSent, dwFlags, lpTo, iToLen, lpOverlapped,
212 lpCompletionRoutine, NULL /* lpThreadId */, &Errno);
213
214 DereferenceProviderByPointer(Provider);
215
216 if (Code == SOCKET_ERROR)
217 WSASetLastError(Errno);
218
219 return Code;
220 }
221
222 /* EOF */