Loading...
Searching...
No Matches
tcp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Alexander Aring <aar@pengutronix.de>
3 * SPDX-FileCopyrightText: 2016 Freie Universität Berlin
4 * SPDX-FileCopyrightText: 2016 HAW Hamburg
5 * SPDX-FileCopyrightText: 2016 Kaspar Schleiser <kaspar@schleiser.de>
6 * SPDX-License-Identifier: LGPL-2.1-only
7 */
8
9#pragma once
10
300
301#include <errno.h>
302#include <stdint.h>
303#include <stdlib.h>
304#include <sys/types.h>
305
306/* net/sock/async/types.h included by net/sock.h needs to re-typedef the
307 * `sock_tcp_t` and `sock_tcp_queue_t` to prevent cyclic includes */
308#if defined (__clang__)
309# pragma clang diagnostic push
310# pragma clang diagnostic ignored "-Wtypedef-redefinition"
311#endif
312
313#include "net/sock.h"
314
315#ifdef __cplusplus
316extern "C" {
317#endif
318
320
327typedef struct sock_tcp sock_tcp_t;
328
336
337#if defined (__clang__)
338# pragma clang diagnostic pop
339#endif
340
372 uint16_t local_port, uint16_t flags);
373
398 sock_tcp_t *queue_array, unsigned queue_len,
399 uint16_t flags);
400
411
420
433
446
459
486 uint32_t timeout);
487
518ssize_t sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len,
519 uint32_t timeout);
520
541ssize_t sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len);
542
543#ifdef __cplusplus
544}
545#endif
546
547#include "sock_types.h"
548
struct sock_tcp sock_tcp_t
forward declare for async
Definition types.h:93
struct sock_tcp_queue sock_tcp_queue_t
forward declare for async
Definition types.h:94
int sock_tcp_get_local(sock_tcp_t *sock, sock_tcp_ep_t *ep)
Gets the local end point of a TCP sock object.
int sock_tcp_listen(sock_tcp_queue_t *queue, const sock_tcp_ep_t *local, sock_tcp_t *queue_array, unsigned queue_len, uint16_t flags)
Listen for an incoming connection request on local end point.
void sock_tcp_stop_listen(sock_tcp_queue_t *queue)
Stops listening on TCP listening queue.
int sock_tcp_connect(sock_tcp_t *sock, const sock_tcp_ep_t *remote, uint16_t local_port, uint16_t flags)
Establishes a new TCP sock connection.
int sock_tcp_accept(sock_tcp_queue_t *queue, sock_tcp_t **sock, uint32_t timeout)
Receives and handles TCP connection requests from other peers.
struct _sock_tl_ep sock_tcp_ep_t
An end point for a TCP sock object.
Definition tcp.h:319
ssize_t sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len, uint32_t timeout)
Reads data from an established TCP stream.
ssize_t sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len)
Writes data to an established TCP stream.
void sock_tcp_disconnect(sock_tcp_t *sock)
Disconnects a TCP connection.
int sock_tcp_queue_get_local(sock_tcp_queue_t *queue, sock_tcp_ep_t *ep)
Gets the local end point of a TCP sock queue object.
int sock_tcp_get_remote(sock_tcp_t *sock, sock_tcp_ep_t *ep)
Gets the remote end point of a TCP sock object.
Common sock API definitions.
Common IP-based transport layer end point.
Definition sock.h:211
TCP queue type.
Definition sock_types.h:114
unsigned short len
Length of the struct sock_tcp_queue::array.
Definition sock_types.h:118
TCP sock type.
Definition sock_types.h:101