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