Loading...
Searching...
No Matches
tcp.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Alexander Aring <aar@pengutronix.de>
3 * Freie Universität Berlin
4 * HAW Hamburg
5 * Kaspar Schleiser <kaspar@schleiser.de>
6 *
7 * This file is subject to the terms and conditions of the GNU Lesser
8 * General Public License v2.1. See the file LICENSE in the top level
9 * directory for more details.
10 */
11
299#ifndef NET_SOCK_TCP_H
300#define NET_SOCK_TCP_H
301
302#include <errno.h>
303#include <stdint.h>
304#include <stdlib.h>
305#include <sys/types.h>
306
307/* net/sock/async/types.h included by net/sock.h needs to re-typedef the
308 * `sock_tcp_t` and `sock_tcp_queue_t` to prevent cyclic includes */
309#if defined (__clang__)
310# pragma clang diagnostic push
311# pragma clang diagnostic ignored "-Wtypedef-redefinition"
312#endif
313
314#include "net/sock.h"
315
316#ifdef __cplusplus
317extern "C" {
318#endif
319
328typedef struct sock_tcp sock_tcp_t;
329
337
338#if defined (__clang__)
339# pragma clang diagnostic pop
340#endif
341
373 uint16_t local_port, uint16_t flags);
374
399 sock_tcp_t *queue_array, unsigned queue_len,
400 uint16_t flags);
401
412
421
434
447
460
487 uint32_t timeout);
488
519ssize_t sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len,
520 uint32_t timeout);
521
542ssize_t sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len);
543
544#ifdef __cplusplus
545}
546#endif
547
548#include "sock_types.h"
549
550#endif /* NET_SOCK_TCP_H */
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.
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:215
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