summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/BIO_s_socket.3
blob: f7aff6a4c8f1566637aea635054f65a635b52dd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
.Dd $Mdocdate: February 16 2015 $
.Dt BIO_S_SOCKET 3
.Os
.Sh NAME
.Nm BIO_s_socket ,
.Nm BIO_new_socket
.Nd socket BIO
.Sh SYNOPSIS
.In openssl/bio.h
.Ft BIO_METHOD *
.Fo BIO_s_socket
.Fa void
.Fc
.Ft long
.Fo BIO_set_fd
.Fa "BIO *b"
.Fa "int fd"
.Fa "long close_flag"
.Fc
.Ft long
.Fo BIO_get_fd
.Fa "BIO *b"
.Fa "int *c"
.Fc
.Ft BIO *
.Fo BIO_new_socket
.Fa "int sock"
.Fa "int close_flag"
.Fc
.Sh DESCRIPTION
.Fn BIO_s_socket
returns the socket BIO method.
This is a wrapper around the platform's socket routines.
.Pp
.Xr BIO_read 3
and
.Xr BIO_write 3
read or write the underlying socket.
.Xr BIO_puts 3
is supported but
.Xr BIO_gets 3
is not.
.Pp
If the close flag is set, then the socket is shut down and closed
when the BIO is freed.
.Pp
.Fn BIO_set_fd
sets the socket of BIO
.Fa b
to
.Fa fd
and the close flag to
.Fa close_flag .
.Pp
.Fn BIO_get_fd
places the socket in
.Fa c
if it is not
.Dv NULL ,
it also returns the socket.
If
.Fa c
is not
.Dv NULL
it should be of type
.Vt "int *" .
.Pp
.Fn BIO_new_socket
returns a socket BIO using
.Fa sock
and
.Fa close_flag .
.Sh NOTES
Socket BIOs also support any relevant functionality of file descriptor BIOs.
.Pp
The reason for having separate file descriptor and socket BIOs
is that on some platforms, sockets are not file descriptors
and use distinct I/O routines.
Windows is one such platform.
Any code mixing the two will not work on all platforms.
.Pp
.Fn BIO_set_fd
and
.Fn BIO_get_fd
are macros.
.Sh RETURN VALUES
.Fn BIO_s_socket
returns the socket BIO method.
.Pp
.Fn BIO_set_fd
always returns 1.
.Pp
.Fn BIO_get_fd
returns the socket or -1 if the BIO has not been initialized.
.Pp
.Fn BIO_new_socket
returns the newly allocated BIO or
.Dv NULL
if an error occurred.