1 .\" $OpenBSD: tls_accept_socket.3,v 1.5 2025年07月07日 10:54:00 schwarze Exp $ 2 .\" 3 .\" Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> 4 .\" Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 5 .\" Copyright (c) 2016 Brent Cook <bcook@openbsd.org> 6 .\" 7 .\" Permission to use, copy, modify, and distribute this software for any 8 .\" purpose with or without fee is hereby granted, provided that the above 9 .\" copyright notice and this permission notice appear in all copies. 10 .\" 11 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 .\" 19 .Dd $Mdocdate: July 7 2025 $ 20 .Dt TLS_ACCEPT_SOCKET 3 21 .Os 22 .Sh NAME 23 .Nm tls_accept_socket , 24 .Nm tls_accept_fds , 25 .Nm tls_accept_cbs 26 .Nd accept an incoming client connection in a TLS server 27 .Sh SYNOPSIS 28 .Lb libtls libssl libcrypto 29 .In tls.h 30 .Ft int 31 .Fo tls_accept_socket 32 .Fa "struct tls *tls" 33 .Fa "struct tls **cctx" 34 .Fa "int socket" 35 .Fc 36 .Ft int 37 .Fo tls_accept_fds 38 .Fa "struct tls *tls" 39 .Fa "struct tls **cctx" 40 .Fa "int fd_read" 41 .Fa "int fd_write" 42 .Fc 43 .Ft int 44 .Fo tls_accept_cbs 45 .Fa "struct tls *tls" 46 .Fa "struct tls **cctx" 47 .Fa "ssize_t (*tls_read_cb)(struct tls *ctx,\ 48 void *buf, size_t buflen, void *cb_arg)" 49 .Fa "ssize_t (*tls_write_cb)(struct tls *ctx,\ 50 const void *buf, size_t buflen, void *cb_arg)" 51 .Fa "void *cb_arg" 52 .Fc 53 .Sh DESCRIPTION 54After creating a TLS server context 55 .Fa tls 56with 57 .Xr tls_server 3 58and configuring it with 59 .Xr tls_configure 3 , 60a server can accept a new client connection by calling 61 .Fn tls_accept_socket 62on an already established socket connection. 63 .Pp 64Alternatively, a new client connection can be accepted over a pair of existing 65file descriptors by calling 66 .Fn tls_accept_fds . 67 .Pp 68Calling 69 .Fn tls_accept_cbs 70allows read and write callback functions to handle data transfers. 71The specified 72 .Fa cb_arg 73parameter is passed back to the functions, 74and can contain a pointer to any caller-specified data. 75 .Pp 76All these functions create a new context suitable for reading and writing 77and return it in 78 .Pf * Fa cctx . 79 .Sh RETURN VALUES 80These functions return 0 on success or -1 on error. 81 .Sh SEE ALSO 82 .Xr tls_close 3 , 83 .Xr tls_config_set_session_id 3 , 84 .Xr tls_configure 3 , 85 .Xr tls_connect 3 , 86 .Xr tls_init 3 , 87 .Xr tls_server 3 88 .Sh HISTORY 89 .Fn tls_accept_socket 90appeared in 91 .Ox 5.6 92and got its final name in 93 .Ox 5.7 . 94 .Pp 95 .Fn tls_accept_fds 96appeared in 97 .Ox 5.8 98and 99 .Fn tls_accept_cbs 100in 101 .Ox 6.1 . 102 .Sh AUTHORS 103 .An Joel Sing Aq Mt jsing@openbsd.org 104 .Pp 105 .An -nosplit 106 .Fn tls_accept_cbs 107was written by 108 .An Tobias Pape Aq Mt tobias@netshed.de . 109