2e8871e006ad34c135dec0d61d39538c88d79ef2
[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 WSARecvFrom(s, &WSABuf, 1, &BytesReceived, (LPDWORD)&flags, from, fromlen, NULL, NULL);
47
48 return BytesReceived;
49 }
50
51
52 INT
53 EXPORT
54 send(
55 IN SOCKET s,
56 IN CONST CHAR FAR* buf,
57 IN INT len,
58 IN INT flags)
59 {
60 UNIMPLEMENTED
61
62 return 0;
63 }
64
65
66 INT
67 EXPORT
68 sendto(
69 IN SOCKET s,
70 IN CONST CHAR FAR* buf,
71 IN INT len,
72 IN INT flags,
73 IN CONST LPSOCKADDR to,
74 IN INT tolen)
75 {
76 DWORD BytesSent;
77 WSABUF WSABuf;
78
79 WS_DbgPrint(MAX_TRACE, ("s (0x%X) buf (0x%X) len (0x%X) flags (0x%X).\n",
80 s, buf, len, flags));
81
82 WSABuf.len = len;
83 WSABuf.buf = (CHAR FAR*)buf;
84
85 return WSASendTo(s, &WSABuf, 1, &BytesSent, flags, to, tolen, NULL, NULL);
86 }
87
88
89 INT
90 EXPORT
91 WSARecv(
92 IN SOCKET s,
93 IN OUT LPWSABUF lpBuffers,
94 IN DWORD dwBufferCount,
95 OUT LPDWORD lpNumberOfBytesRecvd,
96 IN OUT LPDWORD lpFlags,
97 IN LPWSAOVERLAPPED lpOverlapped,
98 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
99 {
100 UNIMPLEMENTED
101
102 return 0;
103 }
104
105
106 INT
107 EXPORT
108 WSARecvDisconnect(
109 IN SOCKET s,
110 OUT LPWSABUF lpInboundDisconnectData)
111 {
112 UNIMPLEMENTED
113
114 return 0;
115 }
116
117
118 INT
119 EXPORT
120 WSARecvFrom(
121 IN SOCKET s,
122 IN OUT LPWSABUF lpBuffers,
123 IN DWORD dwBufferCount,
124 OUT LPDWORD lpNumberOfBytesRecvd,
125 IN OUT LPDWORD lpFlags,
126 OUT LPSOCKADDR lpFrom,
127 IN OUT LPINT lpFromlen,
128 IN LPWSAOVERLAPPED lpOverlapped,
129 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
130 {
131 PCATALOG_ENTRY Provider;
132 INT Errno;
133 INT Code;
134
135 WS_DbgPrint(MAX_TRACE, ("Called.\n"));
136
137 if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) {
138 WSASetLastError(WSAENOTSOCK);
139 return SOCKET_ERROR;
140 }
141
142 assert(Provider->ProcTable.lpWSPRecvFrom);
143
144 Code = Provider->ProcTable.lpWSPRecvFrom(s, lpBuffers, dwBufferCount,
145 lpNumberOfBytesRecvd, lpFlags, lpFrom, lpFromlen, lpOverlapped,
146 lpCompletionRoutine, NULL /* lpThreadId */, &Errno);
147
148 DereferenceProviderByPointer(Provider);
149
150 if (Code == SOCKET_ERROR)
151 WSASetLastError(Errno);
152
153 return Code;
154 }
155
156
157 INT
158 EXPORT
159 WSASend(
160 IN SOCKET s,
161 IN LPWSABUF lpBuffers,
162 IN DWORD dwBufferCount,
163 OUT LPDWORD lpNumberOfBytesSent,
164 IN DWORD dwFlags,
165 IN LPWSAOVERLAPPED lpOverlapped,
166 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
167 {
168 UNIMPLEMENTED
169
170 return 0;
171 }
172
173
174 INT
175 EXPORT
176 WSASendDisconnect(
177 IN SOCKET s,
178 IN LPWSABUF lpOutboundDisconnectData)
179 {
180 UNIMPLEMENTED
181
182 return 0;
183 }
184
185
186 INT
187 EXPORT
188 WSASendTo(
189 IN SOCKET s,
190 IN LPWSABUF lpBuffers,
191 IN DWORD dwBufferCount,
192 OUT LPDWORD lpNumberOfBytesSent,
193 IN DWORD dwFlags,
194 IN CONST LPSOCKADDR lpTo,
195 IN INT iToLen,
196 IN LPWSAOVERLAPPED lpOverlapped,
197 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
198 {
199 PCATALOG_ENTRY Provider;
200 INT Errno;
201 INT Code;
202
203 WS_DbgPrint(MAX_TRACE, ("Called.\n"));
204
205 if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) {
206 WSASetLastError(WSAENOTSOCK);
207 return SOCKET_ERROR;
208 }
209
210 assert(Provider->ProcTable.lpWSPSendTo);
211
212 Code = Provider->ProcTable.lpWSPSendTo(s, lpBuffers, dwBufferCount,
213 lpNumberOfBytesSent, dwFlags, lpTo, iToLen, lpOverlapped,
214 lpCompletionRoutine, NULL /* lpThreadId */, &Errno);
215
216 DereferenceProviderByPointer(Provider);
217
218 if (Code == SOCKET_ERROR)
219 WSASetLastError(Errno);
220
221 return Code;
222 }
223
224 /* EOF */