[1] | 1 | /** @file
|
---|
[8245] | 2 | * IPRT - TCP/IP.
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[76553] | 6 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
[1] | 7 | *
|
---|
| 8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
[5999] | 11 | * General Public License (GPL) as published by the Free Software
|
---|
| 12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 15 | *
|
---|
| 16 | * The contents of this file may alternatively be used under the terms
|
---|
| 17 | * of the Common Development and Distribution License Version 1.0
|
---|
| 18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
| 19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
| 20 | * CDDL are applicable instead of those of the GPL.
|
---|
| 21 | *
|
---|
| 22 | * You may elect to license modified versions of this file under the
|
---|
| 23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[1] | 24 | */
|
---|
| 25 |
|
---|
[76557] | 26 | #ifndef IPRT_INCLUDED_tcp_h
|
---|
| 27 | #define IPRT_INCLUDED_tcp_h
|
---|
[76507] | 28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 29 | # pragma once
|
---|
| 30 | #endif
|
---|
[1] | 31 |
|
---|
| 32 | #include <iprt/cdefs.h>
|
---|
| 33 | #include <iprt/types.h>
|
---|
| 34 | #include <iprt/thread.h>
|
---|
[26588] | 35 | #include <iprt/net.h>
|
---|
[30270] | 36 | #include <iprt/sg.h>
|
---|
[32276] | 37 | #include <iprt/socket.h>
|
---|
[1] | 38 |
|
---|
| 39 | #ifdef IN_RING0
|
---|
| 40 | # error "There are no RTFile APIs available Ring-0 Host Context!"
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 |
|
---|
[20374] | 44 | RT_C_DECLS_BEGIN
|
---|
[1] | 45 |
|
---|
| 46 | /** @defgroup grp_rt_tcp RTTcp - TCP/IP
|
---|
| 47 | * @ingroup grp_rt
|
---|
| 48 | * @{
|
---|
| 49 | */
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | /**
|
---|
| 53 | * Serve a TCP Server connection.
|
---|
| 54 | *
|
---|
| 55 | * @returns iprt status code.
|
---|
| 56 | * @returns VERR_TCP_SERVER_STOP to terminate the server loop forcing
|
---|
| 57 | * the RTTcpCreateServer() call to return.
|
---|
[57944] | 58 | * @param hSocket The socket which the client is connected to. The call
|
---|
| 59 | * will close this socket.
|
---|
[1] | 60 | * @param pvUser User argument.
|
---|
| 61 | */
|
---|
[57944] | 62 | typedef DECLCALLBACK(int) FNRTTCPSERVE(RTSOCKET hSocket, void *pvUser);
|
---|
[1] | 63 | /** Pointer to a RTTCPSERVE(). */
|
---|
| 64 | typedef FNRTTCPSERVE *PFNRTTCPSERVE;
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * Create single connection at a time TCP Server in a separate thread.
|
---|
| 68 | *
|
---|
| 69 | * The thread will loop accepting connections and call pfnServe for
|
---|
| 70 | * each of the incoming connections in turn. The pfnServe function can
|
---|
| 71 | * return VERR_TCP_SERVER_STOP too terminate this loop. RTTcpServerDestroy()
|
---|
| 72 | * should be used to terminate the server.
|
---|
| 73 | *
|
---|
| 74 | * @returns iprt status code.
|
---|
| 75 | * @param pszAddress The address for creating a listening socket.
|
---|
| 76 | * If NULL or empty string the server is bound to all interfaces.
|
---|
| 77 | * @param uPort The port for creating a listening socket.
|
---|
| 78 | * @param enmType The thread type.
|
---|
| 79 | * @param pszThrdName The name of the worker thread.
|
---|
| 80 | * @param pfnServe The function which will serve a new client connection.
|
---|
| 81 | * @param pvUser User argument passed to pfnServe.
|
---|
| 82 | * @param ppServer Where to store the serverhandle.
|
---|
| 83 | */
|
---|
| 84 | RTR3DECL(int) RTTcpServerCreate(const char *pszAddress, unsigned uPort, RTTHREADTYPE enmType, const char *pszThrdName,
|
---|
| 85 | PFNRTTCPSERVE pfnServe, void *pvUser, PPRTTCPSERVER ppServer);
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | * Create single connection at a time TCP Server.
|
---|
| 89 | * The caller must call RTTcpServerListen() to actually start the server.
|
---|
| 90 | *
|
---|
| 91 | * @returns iprt status code.
|
---|
| 92 | * @param pszAddress The address for creating a listening socket.
|
---|
| 93 | * If NULL the server is bound to all interfaces.
|
---|
| 94 | * @param uPort The port for creating a listening socket.
|
---|
| 95 | * @param ppServer Where to store the serverhandle.
|
---|
| 96 | */
|
---|
| 97 | RTR3DECL(int) RTTcpServerCreateEx(const char *pszAddress, uint32_t uPort, PPRTTCPSERVER ppServer);
|
---|
| 98 |
|
---|
| 99 | /**
|
---|
| 100 | * Closes down and frees a TCP Server.
|
---|
| 101 | * This will also terminate any open connections to the server.
|
---|
| 102 | *
|
---|
| 103 | * @returns iprt status code.
|
---|
| 104 | * @param pServer Handle to the server.
|
---|
| 105 | */
|
---|
| 106 | RTR3DECL(int) RTTcpServerDestroy(PRTTCPSERVER pServer);
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | * Listen for incoming connections.
|
---|
| 110 | *
|
---|
| 111 | * The function will loop accepting connections and call pfnServe for
|
---|
| 112 | * each of the incoming connections in turn. The pfnServe function can
|
---|
| 113 | * return VERR_TCP_SERVER_STOP too terminate this loop. A stopped server
|
---|
| 114 | * can only be destroyed.
|
---|
| 115 | *
|
---|
| 116 | * @returns iprt status code.
|
---|
| 117 | * @param pServer The server handle as returned from RTTcpServerCreateEx().
|
---|
| 118 | * @param pfnServe The function which will serve a new client connection.
|
---|
| 119 | * @param pvUser User argument passed to pfnServe.
|
---|
| 120 | */
|
---|
| 121 | RTR3DECL(int) RTTcpServerListen(PRTTCPSERVER pServer, PFNRTTCPSERVE pfnServe, void *pvUser);
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
[33540] | 124 | * Listen and accept one incoming connection.
|
---|
[26683] | 125 | *
|
---|
| 126 | * This is an alternative to RTTcpServerListen for the use the callbacks are not
|
---|
| 127 | * possible.
|
---|
| 128 | *
|
---|
| 129 | * @returns IPRT status code.
|
---|
| 130 | * @retval VERR_TCP_SERVER_SHUTDOWN if shut down by RTTcpServerShutdown.
|
---|
| 131 | * @retval VERR_INTERRUPTED if the listening was interrupted.
|
---|
| 132 | *
|
---|
| 133 | * @param pServer The server handle as returned from RTTcpServerCreateEx().
|
---|
[27787] | 134 | * @param phClientSocket Where to return the socket handle to the client
|
---|
| 135 | * connection (on success only). This must be closed
|
---|
| 136 | * by calling RTTcpServerDisconnectClient2().
|
---|
[26683] | 137 | */
|
---|
[27787] | 138 | RTR3DECL(int) RTTcpServerListen2(PRTTCPSERVER pServer, PRTSOCKET phClientSocket);
|
---|
[26683] | 139 |
|
---|
| 140 | /**
|
---|
[932] | 141 | * Terminate the open connection to the server.
|
---|
| 142 | *
|
---|
| 143 | * @returns iprt status code.
|
---|
| 144 | * @param pServer Handle to the server.
|
---|
| 145 | */
|
---|
| 146 | RTR3DECL(int) RTTcpServerDisconnectClient(PRTTCPSERVER pServer);
|
---|
| 147 |
|
---|
| 148 | /**
|
---|
[27787] | 149 | * Terminates an open client connect when using RTTcpListen2
|
---|
| 150 | *
|
---|
| 151 | * @returns IPRT status code.
|
---|
| 152 | * @param hClientSocket The client socket handle. This will be invalid upon
|
---|
| 153 | * return, whether successful or not. NIL is quietly
|
---|
| 154 | * ignored (VINF_SUCCESS).
|
---|
| 155 | */
|
---|
| 156 | RTR3DECL(int) RTTcpServerDisconnectClient2(RTSOCKET hClientSocket);
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
[23625] | 159 | * Shuts down the server, leaving client connections open.
|
---|
| 160 | *
|
---|
| 161 | * @returns IPRT status code.
|
---|
| 162 | * @param pServer Handle to the server.
|
---|
| 163 | */
|
---|
| 164 | RTR3DECL(int) RTTcpServerShutdown(PRTTCPSERVER pServer);
|
---|
| 165 |
|
---|
| 166 | /**
|
---|
[1] | 167 | * Connect (as a client) to a TCP Server.
|
---|
| 168 | *
|
---|
| 169 | * @returns iprt status code.
|
---|
| 170 | * @param pszAddress The address to connect to.
|
---|
| 171 | * @param uPort The port to connect to.
|
---|
| 172 | * @param pSock Where to store the handle to the established connection.
|
---|
| 173 | */
|
---|
| 174 | RTR3DECL(int) RTTcpClientConnect(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock);
|
---|
| 175 |
|
---|
[45948] | 176 | /** Opaque pointer used by RTTcpClientConnectEx and RTTcpClientCancelConnect. */
|
---|
| 177 | typedef struct RTTCPCLIENTCONNECTCANCEL *PRTTCPCLIENTCONNECTCANCEL;
|
---|
| 178 |
|
---|
[1] | 179 | /**
|
---|
[45948] | 180 | * Connect (as a client) to a TCP Server, extended version.
|
---|
| 181 | *
|
---|
| 182 | * @returns iprt status code.
|
---|
| 183 | * @param pszAddress The address to connect to.
|
---|
| 184 | * @param uPort The port to connect to.
|
---|
| 185 | * @param pSock Where to store the handle to the established connection.
|
---|
[53536] | 186 | * @param cMillies Number of milliseconds to wait for the connect attempt to complete.
|
---|
| 187 | * Use RT_INDEFINITE_WAIT to wait for ever.
|
---|
| 188 | * Use RT_SOCKETCONNECT_DEFAULT_WAIT to wait for the default time
|
---|
| 189 | * configured on the running system.
|
---|
[45948] | 190 | * @param ppCancelCookie Where to store information for canceling the
|
---|
| 191 | * operation (from a different thread). Optional.
|
---|
| 192 | *
|
---|
| 193 | * The pointer _must_ be initialized to NULL before a
|
---|
| 194 | * series of connection attempts begins, i.e. at a time
|
---|
| 195 | * where there will be no RTTcpClientCancelConnect
|
---|
| 196 | * calls racing access. RTTcpClientCancelConnect will
|
---|
| 197 | * set it to a special non-NULL value that causes the
|
---|
| 198 | * current or/and next connect call to fail.
|
---|
| 199 | *
|
---|
| 200 | * @sa RTTcpClientCancelConnect
|
---|
| 201 | */
|
---|
| 202 | RTR3DECL(int) RTTcpClientConnectEx(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock,
|
---|
[53536] | 203 | RTMSINTERVAL cMillies, PRTTCPCLIENTCONNECTCANCEL volatile *ppCancelCookie);
|
---|
[45948] | 204 |
|
---|
| 205 | /**
|
---|
| 206 | * Cancels a RTTcpClientConnectEx call on a different thread.
|
---|
| 207 | *
|
---|
| 208 | * @returns iprt status code.
|
---|
| 209 | * @param ppCancelCookie The address of the cookie pointer shared with the
|
---|
| 210 | * connect call.
|
---|
| 211 | */
|
---|
| 212 | RTR3DECL(int) RTTcpClientCancelConnect(PRTTCPCLIENTCONNECTCANCEL volatile *ppCancelCookie);
|
---|
| 213 |
|
---|
| 214 | /**
|
---|
[1] | 215 | * Close a socket returned by RTTcpClientConnect().
|
---|
| 216 | *
|
---|
| 217 | * @returns iprt status code.
|
---|
[57944] | 218 | * @param hSocket Socket descriptor.
|
---|
[1] | 219 | */
|
---|
[57944] | 220 | RTR3DECL(int) RTTcpClientClose(RTSOCKET hSocket);
|
---|
[1] | 221 |
|
---|
| 222 | /**
|
---|
[32818] | 223 | * Close a socket returned by RTTcpClientConnect().
|
---|
| 224 | *
|
---|
| 225 | * @returns iprt status code.
|
---|
| 226 | * @param hSocket The socket handle.
|
---|
| 227 | * @param fGracefulShutdown If true, try do a graceful shutdown of the
|
---|
| 228 | * outgoing pipe and draining any lingering input.
|
---|
| 229 | * This is sometimes better for the server side.
|
---|
| 230 | * If false, just close the connection without
|
---|
| 231 | * further ado.
|
---|
| 232 | */
|
---|
[57944] | 233 | RTR3DECL(int) RTTcpClientCloseEx(RTSOCKET hSocket, bool fGracefulShutdown);
|
---|
[32818] | 234 |
|
---|
| 235 | /**
|
---|
[70481] | 236 | * Creates connected pair of TCP sockets.
|
---|
| 237 | *
|
---|
| 238 | * @returns IPRT status code.
|
---|
| 239 | * @param phServer Where to return the "server" side of the pair.
|
---|
| 240 | * @param phClient Where to return the "client" side of the pair.
|
---|
[70492] | 241 | * @param fFlags Reserved, must be zero.
|
---|
[70481] | 242 | *
|
---|
| 243 | * @note There is no server or client side, but we gotta call it something.
|
---|
| 244 | */
|
---|
| 245 | RTR3DECL(int) RTTcpCreatePair(PRTSOCKET phServer, PRTSOCKET phClient, uint32_t fFlags);
|
---|
| 246 |
|
---|
| 247 | /**
|
---|
[1] | 248 | * Receive data from a socket.
|
---|
| 249 | *
|
---|
| 250 | * @returns iprt status code.
|
---|
[57944] | 251 | * @param hSocket Socket descriptor.
|
---|
[1] | 252 | * @param pvBuffer Where to put the data we read.
|
---|
| 253 | * @param cbBuffer Read buffer size.
|
---|
| 254 | * @param pcbRead Number of bytes read.
|
---|
| 255 | * If NULL the entire buffer will be filled upon successful return.
|
---|
| 256 | * If not NULL a partial read can be done successfully.
|
---|
| 257 | */
|
---|
[57944] | 258 | RTR3DECL(int) RTTcpRead(RTSOCKET hSocket, void *pvBuffer, size_t cbBuffer, size_t *pcbRead);
|
---|
[1] | 259 |
|
---|
| 260 | /**
|
---|
[27497] | 261 | * Send data to a socket.
|
---|
[1] | 262 | *
|
---|
| 263 | * @returns iprt status code.
|
---|
[26683] | 264 | * @retval VERR_INTERRUPTED if interrupted before anything was written.
|
---|
| 265 | *
|
---|
[57944] | 266 | * @param hSocket Socket descriptor.
|
---|
[1] | 267 | * @param pvBuffer Buffer to write data to socket.
|
---|
| 268 | * @param cbBuffer How much to write.
|
---|
| 269 | */
|
---|
[57944] | 270 | RTR3DECL(int) RTTcpWrite(RTSOCKET hSocket, const void *pvBuffer, size_t cbBuffer);
|
---|
[1] | 271 |
|
---|
| 272 | /**
|
---|
| 273 | * Flush socket write buffers.
|
---|
| 274 | *
|
---|
| 275 | * @returns iprt status code.
|
---|
[57944] | 276 | * @param hSocket Socket descriptor.
|
---|
[1] | 277 | */
|
---|
[57944] | 278 | RTR3DECL(int) RTTcpFlush(RTSOCKET hSocket);
|
---|
[1] | 279 |
|
---|
| 280 | /**
|
---|
[30270] | 281 | * Enables or disables delaying sends to coalesce packets.
|
---|
[27959] | 282 | *
|
---|
| 283 | * The TCP/IP stack usually uses the Nagle algorithm (RFC 896) to implement the
|
---|
| 284 | * coalescing.
|
---|
| 285 | *
|
---|
| 286 | * @returns iprt status code.
|
---|
[57944] | 287 | * @param hSocket Socket descriptor.
|
---|
[30270] | 288 | * @param fEnable When set to true enables coalescing.
|
---|
[27959] | 289 | */
|
---|
[57944] | 290 | RTR3DECL(int) RTTcpSetSendCoalescing(RTSOCKET hSocket, bool fEnable);
|
---|
[27959] | 291 |
|
---|
| 292 | /**
|
---|
[1] | 293 | * Socket I/O multiplexing.
|
---|
| 294 | * Checks if the socket is ready for reading.
|
---|
| 295 | *
|
---|
| 296 | * @returns iprt status code.
|
---|
[57944] | 297 | * @param hSocket Socket descriptor.
|
---|
[1] | 298 | * @param cMillies Number of milliseconds to wait for the socket.
|
---|
| 299 | * Use RT_INDEFINITE_WAIT to wait for ever.
|
---|
| 300 | */
|
---|
[57944] | 301 | RTR3DECL(int) RTTcpSelectOne(RTSOCKET hSocket, RTMSINTERVAL cMillies);
|
---|
[1] | 302 |
|
---|
[32276] | 303 | /**
|
---|
| 304 | * Socket I/O multiplexing
|
---|
| 305 | * Checks if the socket is ready for one of the given events.
|
---|
| 306 | *
|
---|
| 307 | * @returns iprt status code.
|
---|
[57944] | 308 | * @param hSocket Socket descriptor.
|
---|
[32276] | 309 | * @param fEvents Event mask to wait for.
|
---|
| 310 | * Use the RTSOCKET_EVT_* defines.
|
---|
| 311 | * @param pfEvents Where to store the event mask on return.
|
---|
| 312 | * @param cMillies Number of milliseconds to wait for the socket.
|
---|
| 313 | * Use RT_INDEFINITE_WAIT to wait for ever.
|
---|
| 314 | */
|
---|
[57944] | 315 | RTR3DECL(int) RTTcpSelectOneEx(RTSOCKET hSocket, uint32_t fEvents, uint32_t *pfEvents, RTMSINTERVAL cMillies);
|
---|
[1] | 316 |
|
---|
| 317 | #if 0 /* skipping these for now - RTTcpServer* handles this. */
|
---|
| 318 | /**
|
---|
| 319 | * Listen for connection on a socket.
|
---|
| 320 | *
|
---|
| 321 | * @returns iprt status code.
|
---|
[57944] | 322 | * @param hSocket Socket descriptor.
|
---|
[1] | 323 | * @param cBackLog The maximum length the queue of pending connections
|
---|
| 324 | * may grow to.
|
---|
| 325 | */
|
---|
[57944] | 326 | RTR3DECL(int) RTTcpListen(RTSOCKET hSocket, int cBackLog);
|
---|
[1] | 327 |
|
---|
| 328 | /**
|
---|
| 329 | * Accept a connection on a socket.
|
---|
| 330 | *
|
---|
| 331 | * @returns iprt status code.
|
---|
[57944] | 332 | * @param hSocket Socket descriptor.
|
---|
[1] | 333 | * @param uPort The port for accepting connection.
|
---|
| 334 | * @param pSockAccepted Where to store the handle to the accepted connection.
|
---|
| 335 | */
|
---|
[57944] | 336 | RTR3DECL(int) RTTcpAccept(RTSOCKET hSocket, unsigned uPort, PRTSOCKET pSockAccepted);
|
---|
[1] | 337 |
|
---|
| 338 | #endif
|
---|
| 339 |
|
---|
[26588] | 340 | /**
|
---|
[26915] | 341 | * Gets the address of the local side.
|
---|
| 342 | *
|
---|
| 343 | * @returns IPRT status code.
|
---|
[57944] | 344 | * @param hSocket Socket descriptor.
|
---|
[26915] | 345 | * @param pAddr Where to store the local address on success.
|
---|
| 346 | */
|
---|
[57944] | 347 | RTR3DECL(int) RTTcpGetLocalAddress(RTSOCKET hSocket, PRTNETADDR pAddr);
|
---|
[26915] | 348 |
|
---|
| 349 | /**
|
---|
[26588] | 350 | * Gets the address of the other party.
|
---|
| 351 | *
|
---|
| 352 | * @returns IPRT status code.
|
---|
[57944] | 353 | * @param hSocket Socket descriptor.
|
---|
[26588] | 354 | * @param pAddr Where to store the peer address on success.
|
---|
| 355 | */
|
---|
[57944] | 356 | RTR3DECL(int) RTTcpGetPeerAddress(RTSOCKET hSocket, PRTNETADDR pAddr);
|
---|
[1] | 357 |
|
---|
[30270] | 358 | /**
|
---|
| 359 | * Send data from a scatter/gather buffer to a socket.
|
---|
| 360 | *
|
---|
| 361 | * @returns iprt status code.
|
---|
| 362 | * @retval VERR_INTERRUPTED if interrupted before anything was written.
|
---|
| 363 | *
|
---|
[57944] | 364 | * @param hSocket Socket descriptor.
|
---|
[30270] | 365 | * @param pSgBuf Scatter/gather buffer to write data to socket.
|
---|
| 366 | */
|
---|
[57944] | 367 | RTR3DECL(int) RTTcpSgWrite(RTSOCKET hSocket, PCRTSGBUF pSgBuf);
|
---|
[30270] | 368 |
|
---|
[30468] | 369 |
|
---|
| 370 | /**
|
---|
| 371 | * Send data from multiple buffers to a socket.
|
---|
| 372 | *
|
---|
| 373 | * This is convenience wrapper around the RTSocketSgWrite and RTSgBufInit calls
|
---|
| 374 | * for lazy coders. The "L" in the function name is short for "list" just like
|
---|
| 375 | * in the execl libc API.
|
---|
| 376 | *
|
---|
| 377 | * @returns IPRT status code.
|
---|
| 378 | * @retval VERR_INTERRUPTED if interrupted before anything was written.
|
---|
| 379 | *
|
---|
| 380 | * @param hSocket The socket handle.
|
---|
| 381 | * @param cSegs The number of data segments in the following
|
---|
| 382 | * ellipsis.
|
---|
| 383 | * @param ... Pairs of buffer pointers (void const *) and buffer
|
---|
| 384 | * sizes (size_t). Make 101% sure the pointer is
|
---|
| 385 | * really size_t.
|
---|
| 386 | */
|
---|
| 387 | RTR3DECL(int) RTTcpSgWriteL(RTSOCKET hSocket, size_t cSegs, ...);
|
---|
| 388 |
|
---|
| 389 | /**
|
---|
| 390 | * Send data from multiple buffers to a socket.
|
---|
| 391 | *
|
---|
| 392 | * This is convenience wrapper around the RTSocketSgWrite and RTSgBufInit calls
|
---|
| 393 | * for lazy coders. The "L" in the function name is short for "list" just like
|
---|
| 394 | * in the execl libc API.
|
---|
| 395 | *
|
---|
| 396 | * @returns IPRT status code.
|
---|
| 397 | * @retval VERR_INTERRUPTED if interrupted before anything was written.
|
---|
| 398 | *
|
---|
| 399 | * @param hSocket The socket handle.
|
---|
| 400 | * @param cSegs The number of data segments in the following
|
---|
| 401 | * argument list.
|
---|
| 402 | * @param va Pairs of buffer pointers (void const *) and buffer
|
---|
| 403 | * sizes (size_t). Make 101% sure the pointer is
|
---|
| 404 | * really size_t.
|
---|
| 405 | */
|
---|
| 406 | RTR3DECL(int) RTTcpSgWriteLV(RTSOCKET hSocket, size_t cSegs, va_list va);
|
---|
| 407 |
|
---|
[31103] | 408 | /**
|
---|
| 409 | * Receive data from a socket.
|
---|
| 410 | *
|
---|
| 411 | * This version doesn't block if there is no data on the socket.
|
---|
| 412 | *
|
---|
| 413 | * @returns IPRT status code.
|
---|
| 414 | *
|
---|
[57944] | 415 | * @param hSocket Socket descriptor.
|
---|
[31103] | 416 | * @param pvBuffer Where to put the data we read.
|
---|
| 417 | * @param cbBuffer Read buffer size.
|
---|
| 418 | * @param pcbRead Number of bytes read.
|
---|
| 419 | */
|
---|
[57944] | 420 | RTR3DECL(int) RTTcpReadNB(RTSOCKET hSocket, void *pvBuffer, size_t cbBuffer, size_t *pcbRead);
|
---|
[31103] | 421 |
|
---|
| 422 | /**
|
---|
| 423 | * Send data to a socket.
|
---|
| 424 | *
|
---|
| 425 | * This version doesn't block if there is not enough room for the message.
|
---|
| 426 | *
|
---|
| 427 | * @returns IPRT status code.
|
---|
| 428 | *
|
---|
[57944] | 429 | * @param hSocket Socket descriptor.
|
---|
[31103] | 430 | * @param pvBuffer Buffer to write data to socket.
|
---|
| 431 | * @param cbBuffer How much to write.
|
---|
| 432 | * @param pcbWritten Number of bytes written.
|
---|
| 433 | */
|
---|
[57944] | 434 | RTR3DECL(int) RTTcpWriteNB(RTSOCKET hSocket, const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten);
|
---|
[31103] | 435 |
|
---|
| 436 | /**
|
---|
| 437 | * Send data from a scatter/gather buffer to a socket.
|
---|
| 438 | *
|
---|
| 439 | * This version doesn't block if there is not enough room for the message.
|
---|
| 440 | *
|
---|
| 441 | * @returns iprt status code.
|
---|
| 442 | * @retval VERR_INTERRUPTED if interrupted before anything was written.
|
---|
| 443 | *
|
---|
[57944] | 444 | * @param hSocket Socket descriptor.
|
---|
[31103] | 445 | * @param pSgBuf Scatter/gather buffer to write data to socket.
|
---|
| 446 | * @param pcbWritten Number of bytes written.
|
---|
| 447 | */
|
---|
[57944] | 448 | RTR3DECL(int) RTTcpSgWriteNB(RTSOCKET hSocket, PCRTSGBUF pSgBuf, size_t *pcbWritten);
|
---|
[31103] | 449 |
|
---|
| 450 |
|
---|
| 451 | /**
|
---|
| 452 | * Send data from multiple buffers to a socket.
|
---|
| 453 | *
|
---|
| 454 | * This version doesn't block if there is not enough room for the message.
|
---|
| 455 | * This is convenience wrapper around the RTSocketSgWrite and RTSgBufInit calls
|
---|
| 456 | * for lazy coders. The "L" in the function name is short for "list" just like
|
---|
| 457 | * in the execl libc API.
|
---|
| 458 | *
|
---|
| 459 | * @returns IPRT status code.
|
---|
| 460 | *
|
---|
| 461 | * @param hSocket The socket handle.
|
---|
| 462 | * @param cSegs The number of data segments in the following
|
---|
| 463 | * ellipsis.
|
---|
| 464 | * @param pcbWritten Number of bytes written.
|
---|
| 465 | * @param ... Pairs of buffer pointers (void const *) and buffer
|
---|
| 466 | * sizes (size_t). Make 101% sure the pointer is
|
---|
| 467 | * really size_t.
|
---|
| 468 | */
|
---|
| 469 | RTR3DECL(int) RTTcpSgWriteLNB(RTSOCKET hSocket, size_t cSegs, size_t *pcbWritten, ...);
|
---|
| 470 |
|
---|
| 471 | /**
|
---|
| 472 | * Send data from multiple buffers to a socket.
|
---|
| 473 | *
|
---|
| 474 | * This version doesn't block if there is not enough room for the message.
|
---|
| 475 | * This is convenience wrapper around the RTSocketSgWrite and RTSgBufInit calls
|
---|
| 476 | * for lazy coders. The "L" in the function name is short for "list" just like
|
---|
| 477 | * in the execl libc API.
|
---|
| 478 | *
|
---|
| 479 | * @returns IPRT status code.
|
---|
| 480 | *
|
---|
| 481 | * @param hSocket The socket handle.
|
---|
| 482 | * @param cSegs The number of data segments in the following
|
---|
| 483 | * argument list.
|
---|
| 484 | * @param pcbWritten Number of bytes written.
|
---|
| 485 | * @param va Pairs of buffer pointers (void const *) and buffer
|
---|
| 486 | * sizes (size_t). Make 101% sure the pointer is
|
---|
| 487 | * really size_t.
|
---|
| 488 | */
|
---|
| 489 | RTR3DECL(int) RTTcpSgWriteLVNB(RTSOCKET hSocket, size_t cSegs, size_t *pcbWritten, va_list va);
|
---|
| 490 |
|
---|
[1] | 491 | /** @} */
|
---|
[20374] | 492 | RT_C_DECLS_END
|
---|
[1] | 493 |
|
---|
[76585] | 494 | #endif /* !IPRT_INCLUDED_tcp_h */
|
---|
[1] | 495 |
|
---|