.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.