diff options
Diffstat (limited to 'src/lib/libcrypto/man/BIO_s_connect.3')
| -rw-r--r-- | src/lib/libcrypto/man/BIO_s_connect.3 | 503 |
1 files changed, 0 insertions, 503 deletions
diff --git a/src/lib/libcrypto/man/BIO_s_connect.3 b/src/lib/libcrypto/man/BIO_s_connect.3 deleted file mode 100644 index bce68a26b9..0000000000 --- a/src/lib/libcrypto/man/BIO_s_connect.3 +++ /dev/null | |||
| @@ -1,503 +0,0 @@ | |||
| 1 | .\" $OpenBSD: BIO_s_connect.3,v 1.19 2023/04/30 13:53:54 schwarze Exp $ | ||
| 2 | .\" full merge up to: OpenSSL 0e474b8b Nov 1 15:45:49 2015 +0100 | ||
| 3 | .\" | ||
| 4 | .\" This file is a derived work. | ||
| 5 | .\" The changes are covered by the following Copyright and license: | ||
| 6 | .\" | ||
| 7 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> | ||
| 8 | .\" | ||
| 9 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 10 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 11 | .\" copyright notice and this permission notice appear in all copies. | ||
| 12 | .\" | ||
| 13 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 14 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 15 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 16 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 17 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 18 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 19 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 20 | .\" | ||
| 21 | .\" The original file was written by Dr. Stephen Henson <steve@openssl.org>. | ||
| 22 | .\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved. | ||
| 23 | .\" | ||
| 24 | .\" Redistribution and use in source and binary forms, with or without | ||
| 25 | .\" modification, are permitted provided that the following conditions | ||
| 26 | .\" are met: | ||
| 27 | .\" | ||
| 28 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 29 | .\" notice, this list of conditions and the following disclaimer. | ||
| 30 | .\" | ||
| 31 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 32 | .\" notice, this list of conditions and the following disclaimer in | ||
| 33 | .\" the documentation and/or other materials provided with the | ||
| 34 | .\" distribution. | ||
| 35 | .\" | ||
| 36 | .\" 3. All advertising materials mentioning features or use of this | ||
| 37 | .\" software must display the following acknowledgment: | ||
| 38 | .\" "This product includes software developed by the OpenSSL Project | ||
| 39 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 40 | .\" | ||
| 41 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 42 | .\" endorse or promote products derived from this software without | ||
| 43 | .\" prior written permission. For written permission, please contact | ||
| 44 | .\" openssl-core@openssl.org. | ||
| 45 | .\" | ||
| 46 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 47 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 48 | .\" permission of the OpenSSL Project. | ||
| 49 | .\" | ||
| 50 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 51 | .\" acknowledgment: | ||
| 52 | .\" "This product includes software developed by the OpenSSL Project | ||
| 53 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 54 | .\" | ||
| 55 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 56 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 57 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 58 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 59 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 60 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 61 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 62 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 63 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 64 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 65 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 66 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 67 | .\" | ||
| 68 | .Dd $Mdocdate: April 30 2023 $ | ||
| 69 | .Dt BIO_S_CONNECT 3 | ||
| 70 | .Os | ||
| 71 | .Sh NAME | ||
| 72 | .Nm BIO_s_connect , | ||
| 73 | .Nm BIO_new_connect , | ||
| 74 | .Nm BIO_set_conn_hostname , | ||
| 75 | .Nm BIO_set_conn_port , | ||
| 76 | .Nm BIO_set_conn_ip , | ||
| 77 | .Nm BIO_set_conn_int_port , | ||
| 78 | .Nm BIO_get_conn_hostname , | ||
| 79 | .Nm BIO_get_conn_port , | ||
| 80 | .Nm BIO_get_conn_ip , | ||
| 81 | .Nm BIO_get_conn_int_port , | ||
| 82 | .Nm BIO_set_nbio , | ||
| 83 | .Nm BIO_do_connect | ||
| 84 | .Nd connect BIO | ||
| 85 | .Sh SYNOPSIS | ||
| 86 | .In openssl/bio.h | ||
| 87 | .Ft const BIO_METHOD * | ||
| 88 | .Fo BIO_s_connect | ||
| 89 | .Fa void | ||
| 90 | .Fc | ||
| 91 | .Ft BIO * | ||
| 92 | .Fo BIO_new_connect | ||
| 93 | .Fa "const char *name" | ||
| 94 | .Fc | ||
| 95 | .Ft long | ||
| 96 | .Fo BIO_set_conn_hostname | ||
| 97 | .Fa "BIO *b" | ||
| 98 | .Fa "char *name" | ||
| 99 | .Fc | ||
| 100 | .Ft long | ||
| 101 | .Fo BIO_set_conn_port | ||
| 102 | .Fa "BIO *b" | ||
| 103 | .Fa "char *port" | ||
| 104 | .Fc | ||
| 105 | .Ft long | ||
| 106 | .Fo BIO_set_conn_ip | ||
| 107 | .Fa "BIO *b" | ||
| 108 | .Fa "char *ip" | ||
| 109 | .Fc | ||
| 110 | .Ft long | ||
| 111 | .Fo BIO_set_conn_int_port | ||
| 112 | .Fa "BIO *b" | ||
| 113 | .Fa "char *port" | ||
| 114 | .Fc | ||
| 115 | .Ft char * | ||
| 116 | .Fo BIO_get_conn_hostname | ||
| 117 | .Fa "BIO *b" | ||
| 118 | .Fc | ||
| 119 | .Ft char * | ||
| 120 | .Fo BIO_get_conn_port | ||
| 121 | .Fa "BIO *b" | ||
| 122 | .Fc | ||
| 123 | .Ft char * | ||
| 124 | .Fo BIO_get_conn_ip | ||
| 125 | .Fa "BIO *b" | ||
| 126 | .Fc | ||
| 127 | .Ft long | ||
| 128 | .Fo BIO_get_conn_int_port | ||
| 129 | .Fa "BIO *b" | ||
| 130 | .Fc | ||
| 131 | .Ft long | ||
| 132 | .Fo BIO_set_nbio | ||
| 133 | .Fa "BIO *b" | ||
| 134 | .Fa "long n" | ||
| 135 | .Fc | ||
| 136 | .Ft long | ||
| 137 | .Fo BIO_do_connect | ||
| 138 | .Fa "BIO *b" | ||
| 139 | .Fc | ||
| 140 | .Sh DESCRIPTION | ||
| 141 | .Fn BIO_s_connect | ||
| 142 | returns the connect BIO method. | ||
| 143 | This is a wrapper around the platform's TCP/IP socket connection routines. | ||
| 144 | .Pp | ||
| 145 | Using connect BIOs, TCP/IP connections can be made and data | ||
| 146 | transferred using only BIO routines. | ||
| 147 | In this way any platform specific operations | ||
| 148 | are hidden by the BIO abstraction. | ||
| 149 | .Pp | ||
| 150 | Read and write operations on a connect BIO will perform I/O | ||
| 151 | on the underlying connection. | ||
| 152 | If no connection is established and the port and hostname (see below) | ||
| 153 | is set up properly, then a connection is established first. | ||
| 154 | .Pp | ||
| 155 | Connect BIOs support | ||
| 156 | .Xr BIO_puts 3 | ||
| 157 | but not | ||
| 158 | .Xr BIO_gets 3 . | ||
| 159 | .Pp | ||
| 160 | If the close flag is set on a connect BIO, then any active connection | ||
| 161 | is shutdown and the socket closed when the BIO is freed. | ||
| 162 | .Pp | ||
| 163 | Calling | ||
| 164 | .Xr BIO_reset 3 | ||
| 165 | on a connect BIO will close any active connection and reset the BIO | ||
| 166 | into a state where it can connect to the same host again. | ||
| 167 | .Pp | ||
| 168 | .Xr BIO_get_fd 3 | ||
| 169 | places the underlying socket in | ||
| 170 | .Fa c | ||
| 171 | if it is not | ||
| 172 | .Dv NULL | ||
| 173 | and also returns the socket. | ||
| 174 | If | ||
| 175 | .Fa c | ||
| 176 | is not | ||
| 177 | .Dv NULL , | ||
| 178 | it should be of type | ||
| 179 | .Vt "int *" . | ||
| 180 | .Pp | ||
| 181 | .Xr BIO_set_info_callback 3 | ||
| 182 | and | ||
| 183 | .Xr BIO_callback_ctrl 3 | ||
| 184 | with a | ||
| 185 | .Fa cmd | ||
| 186 | of | ||
| 187 | .Dv BIO_CTRL_SET_CALLBACK | ||
| 188 | save the pointer to the | ||
| 189 | .Fa cb | ||
| 190 | function internally in | ||
| 191 | .Fa b | ||
| 192 | and | ||
| 193 | .Xr BIO_get_info_callback 3 | ||
| 194 | retrieves this function pointer. | ||
| 195 | If such an info callback is installed, it is invoked whenever | ||
| 196 | a state change or error occurs in the connect BIO state machine. | ||
| 197 | The arguments of the callback include the new | ||
| 198 | .Fa state | ||
| 199 | in case of a state change or the old | ||
| 200 | .Fa state | ||
| 201 | in case of an error and the value | ||
| 202 | .Fa res | ||
| 203 | that the state machine would return to whatever operation invoked it | ||
| 204 | if no info callback had been installed. | ||
| 205 | If an info callback is installed, the state machine | ||
| 206 | returns the return value of the info callback instead. | ||
| 207 | Consequently, the info callback is supposed to usually return | ||
| 208 | .Fa res . | ||
| 209 | The precise effect of the return value depends on which operation | ||
| 210 | the state machine was invoked from. | ||
| 211 | Usually, \-1 is used to indicate failure and return values less than | ||
| 212 | or equal to zero abort the operation in question, whereas positive | ||
| 213 | values indicate success and allow the operation to proceed. | ||
| 214 | .Pp | ||
| 215 | The | ||
| 216 | .Fa state | ||
| 217 | constants passed to the callback are named according to | ||
| 218 | which operation needs to be performed next. | ||
| 219 | They are listed here in the order the states are passed through: | ||
| 220 | .Pp | ||
| 221 | .Bl -tag -width BIO_CONN_S_BLOCKED_CONNECT -offset 3n -compact | ||
| 222 | .It Dv BIO_CONN_S_BEFORE | ||
| 223 | The BIO is idle and no connection has been initiated yet. | ||
| 224 | .It Dv BIO_CONN_S_GET_IP | ||
| 225 | The hostname to connect to needs to be converted to an IP address. | ||
| 226 | .It Dv BIO_CONN_S_GET_PORT | ||
| 227 | The service name to connect to needs to be converted to a TCP port number. | ||
| 228 | .It Dv BIO_CONN_S_CREATE_SOCKET | ||
| 229 | The TCP socket needs to be created with the | ||
| 230 | .Xr socket 2 | ||
| 231 | system call. | ||
| 232 | .It Dv BIO_CONN_S_NBIO | ||
| 233 | Socket options may need to be set using | ||
| 234 | .Xr fcntl 2 | ||
| 235 | and | ||
| 236 | .Xr setsockopt 2 . | ||
| 237 | .It Dv BIO_CONN_S_CONNECT | ||
| 238 | The connection needs to be initiated with the | ||
| 239 | .Xr connect 2 | ||
| 240 | system call. | ||
| 241 | .It Dv BIO_CONN_S_BLOCKED_CONNECT | ||
| 242 | The | ||
| 243 | .Xr connect 2 | ||
| 244 | system call would have blocked and needs to be tried again. | ||
| 245 | .It Dv BIO_CONN_S_OK | ||
| 246 | The connection has been established and can now be used to transfer data. | ||
| 247 | .El | ||
| 248 | .Pp | ||
| 249 | .Fn BIO_set_conn_hostname | ||
| 250 | uses the string | ||
| 251 | .Fa name | ||
| 252 | to set the hostname. | ||
| 253 | The hostname can be an IP address. | ||
| 254 | The hostname can also include the port in the form | ||
| 255 | .Ar hostname : Ns Ar port . | ||
| 256 | It is also acceptable to use the forms | ||
| 257 | .Ar hostname Ns / Ns Pa any/other/path | ||
| 258 | or | ||
| 259 | .Ar hostname : Ns Ar port Ns / Ns Pa any/other/path . | ||
| 260 | .Pp | ||
| 261 | .Fn BIO_set_conn_port | ||
| 262 | sets the port to | ||
| 263 | .Fa port . | ||
| 264 | .Fa port | ||
| 265 | is looked up as a service using | ||
| 266 | .Xr getaddrinfo 3 . | ||
| 267 | .Pp | ||
| 268 | .Fn BIO_set_conn_ip | ||
| 269 | sets the IP address to | ||
| 270 | .Fa ip | ||
| 271 | using binary form i.e. four bytes specifying the IP address | ||
| 272 | in big-endian form. | ||
| 273 | .Pp | ||
| 274 | .Fn BIO_set_conn_int_port | ||
| 275 | sets the port using | ||
| 276 | .Fa port . | ||
| 277 | .Fa port | ||
| 278 | should | ||
| 279 | be of type | ||
| 280 | .Vt "int *" . | ||
| 281 | .Pp | ||
| 282 | .Fn BIO_get_conn_hostname | ||
| 283 | returns the hostname of the connect BIO or | ||
| 284 | .Dv NULL | ||
| 285 | if the BIO is initialized but no hostname is set. | ||
| 286 | This return value is an internal pointer which should not be modified. | ||
| 287 | .Pp | ||
| 288 | .Fn BIO_get_conn_port | ||
| 289 | returns the port as a string. | ||
| 290 | This return value is an internal pointer which should not be modified. | ||
| 291 | .Pp | ||
| 292 | .Fn BIO_get_conn_ip | ||
| 293 | returns the IP address in binary form. | ||
| 294 | .Pp | ||
| 295 | .Fn BIO_get_conn_int_port | ||
| 296 | returns the port as an | ||
| 297 | .Vt int . | ||
| 298 | .Pp | ||
| 299 | .Fn BIO_set_nbio | ||
| 300 | sets the non-blocking I/O flag to | ||
| 301 | .Fa n . | ||
| 302 | If | ||
| 303 | .Fa n | ||
| 304 | is zero then blocking I/O is set. | ||
| 305 | If | ||
| 306 | .Fa n | ||
| 307 | is 1 then non-blocking I/O is set. | ||
| 308 | Blocking I/O is the default. | ||
| 309 | The call to | ||
| 310 | .Fn BIO_set_nbio | ||
| 311 | should be made before the connection is established | ||
| 312 | because non-blocking I/O is set during the connect process. | ||
| 313 | .Pp | ||
| 314 | .Fn BIO_new_connect | ||
| 315 | combines | ||
| 316 | .Xr BIO_new 3 | ||
| 317 | and | ||
| 318 | .Fn BIO_set_conn_hostname | ||
| 319 | into a single call. | ||
| 320 | It creates a new connect BIO with | ||
| 321 | .Fa name . | ||
| 322 | .Pp | ||
| 323 | .Fn BIO_do_connect | ||
| 324 | attempts to connect the supplied BIO. | ||
| 325 | It returns 1 if the connection was established successfully. | ||
| 326 | A zero or negative value is returned if the connection | ||
| 327 | could not be established. | ||
| 328 | The call | ||
| 329 | .Xr BIO_should_retry 3 | ||
| 330 | should be used for non-blocking connect BIOs | ||
| 331 | to determine if the call should be retried. | ||
| 332 | .Pp | ||
| 333 | If blocking I/O is set then a non-positive return value from any | ||
| 334 | I/O call is caused by an error condition, although a zero return | ||
| 335 | will normally mean that the connection was closed. | ||
| 336 | .Pp | ||
| 337 | If the port name is supplied as part of the host name then this will | ||
| 338 | override any value set with | ||
| 339 | .Fn BIO_set_conn_port . | ||
| 340 | This may be undesirable if the application does not wish to allow | ||
| 341 | connection to arbitrary ports. | ||
| 342 | This can be avoided by checking for the presence of the | ||
| 343 | .Sq \&: | ||
| 344 | character in the passed hostname and either indicating an error | ||
| 345 | or truncating the string at that point. | ||
| 346 | .Pp | ||
| 347 | The values returned by | ||
| 348 | .Fn BIO_get_conn_hostname , | ||
| 349 | .Fn BIO_get_conn_port , | ||
| 350 | .Fn BIO_get_conn_ip , | ||
| 351 | and | ||
| 352 | .Fn BIO_get_conn_int_port | ||
| 353 | are updated when a connection attempt is made. | ||
| 354 | Before any connection attempt the values returned | ||
| 355 | are those set by the application itself. | ||
| 356 | .Pp | ||
| 357 | Applications do not have to call | ||
| 358 | .Fn BIO_do_connect | ||
| 359 | but may wish to do so to separate the connection process | ||
| 360 | from other I/O processing. | ||
| 361 | .Pp | ||
| 362 | If non-blocking I/O is set, | ||
| 363 | then retries will be requested as appropriate. | ||
| 364 | .Pp | ||
| 365 | In addition to | ||
| 366 | .Xr BIO_should_read 3 | ||
| 367 | and | ||
| 368 | .Xr BIO_should_write 3 | ||
| 369 | it is also possible for | ||
| 370 | .Xr BIO_should_io_special 3 | ||
| 371 | to be true during the initial connection process with the reason | ||
| 372 | .Dv BIO_RR_CONNECT . | ||
| 373 | If this is returned, it is an indication | ||
| 374 | that a connection attempt would block. | ||
| 375 | The application should then take appropriate action to wait | ||
| 376 | until the underlying socket has connected and retry the call. | ||
| 377 | .Pp | ||
| 378 | When a chain containing a connect BIO is copied with | ||
| 379 | .Xr BIO_dup_chain 3 , | ||
| 380 | .Fn BIO_set_conn_hostname , | ||
| 381 | .Fn BIO_set_conn_port , | ||
| 382 | .Fn BIO_set_nbio , | ||
| 383 | and | ||
| 384 | .Xr BIO_set_info_callback 3 | ||
| 385 | are called internally to automatically copy the hostname, port, | ||
| 386 | non-blocking I/O flag, and info callback from the original BIO object | ||
| 387 | to the new one. | ||
| 388 | .Pp | ||
| 389 | .Xr BIO_ctrl 3 | ||
| 390 | .Fa cmd | ||
| 391 | and | ||
| 392 | .Fa larg | ||
| 393 | arguments correspond to macros as follows: | ||
| 394 | .Bl -column BIO_C_DO_STATE_MACHINE larg BIO_get_conn_hostname(3) -offset 3n | ||
| 395 | .It Fa cmd No constant Ta Fa larg Ta corresponding macro | ||
| 396 | .It Dv BIO_C_DO_STATE_MACHINE Ta 0 Ta Fn BIO_do_connect | ||
| 397 | .It Dv BIO_C_GET_CONNECT Ta 0 Ta Fn BIO_get_conn_hostname | ||
| 398 | .It Ta 1 Ta Fn BIO_get_conn_port | ||
| 399 | .It Ta 2 Ta Fn BIO_get_conn_ip | ||
| 400 | .It Ta 3 Ta Fn BIO_get_conn_int_port | ||
| 401 | .It Dv BIO_C_GET_FD Ta 0 Ta Xr BIO_get_fd 3 | ||
| 402 | .It Dv BIO_C_SET_CONNECT Ta 0 Ta Fn BIO_set_conn_hostname | ||
| 403 | .It Ta 1 Ta Fn BIO_set_conn_port | ||
| 404 | .It Ta 2 Ta Fn BIO_set_conn_ip | ||
| 405 | .It Ta 3 Ta Fn BIO_set_conn_int_port | ||
| 406 | .It Dv BIO_C_SET_NBIO Ta Fa n Ta Fn BIO_set_nbio | ||
| 407 | .It Dv BIO_CTRL_GET_CLOSE Ta 0 Ta Xr BIO_get_close 3 | ||
| 408 | .It Dv BIO_CTRL_RESET Ta 0 Ta Xr BIO_reset 3 | ||
| 409 | .It Dv BIO_CTRL_SET_CLOSE Ta Fa flag Ta Xr BIO_set_close 3 | ||
| 410 | .El | ||
| 411 | .Sh RETURN VALUES | ||
| 412 | .Fn BIO_s_connect | ||
| 413 | returns the connect BIO method. | ||
| 414 | .Pp | ||
| 415 | When called on a connect BIO object, | ||
| 416 | .Xr BIO_method_type 3 | ||
| 417 | returns the constant | ||
| 418 | .Dv BIO_TYPE_CONNECT | ||
| 419 | and | ||
| 420 | .Xr BIO_method_name 3 | ||
| 421 | returns a pointer to the static string | ||
| 422 | .Qq socket connect . | ||
| 423 | .Pp | ||
| 424 | .Xr BIO_get_fd 3 | ||
| 425 | returns the socket or -1 if the BIO has not been initialized. | ||
| 426 | .Pp | ||
| 427 | .Fn BIO_set_conn_hostname , | ||
| 428 | .Fn BIO_set_conn_port , | ||
| 429 | .Fn BIO_set_conn_ip , | ||
| 430 | and | ||
| 431 | .Fn BIO_set_conn_int_port | ||
| 432 | always return 1. | ||
| 433 | .Pp | ||
| 434 | .Fn BIO_get_conn_hostname | ||
| 435 | returns the connected hostname or | ||
| 436 | .Dv NULL | ||
| 437 | if none is set. | ||
| 438 | .Pp | ||
| 439 | .Fn BIO_get_conn_port | ||
| 440 | returns a string representing the connected port or | ||
| 441 | .Dv NULL | ||
| 442 | if not set. | ||
| 443 | .Pp | ||
| 444 | .Fn BIO_get_conn_ip | ||
| 445 | returns a pointer to the connected IP address in binary form | ||
| 446 | or all zeros if not set. | ||
| 447 | .Pp | ||
| 448 | .Fn BIO_get_conn_int_port | ||
| 449 | returns the connected port or 0 if none was set. | ||
| 450 | .Pp | ||
| 451 | .Fn BIO_set_nbio | ||
| 452 | always returns 1. | ||
| 453 | .Pp | ||
| 454 | .Fn BIO_do_connect | ||
| 455 | returns 1 if the connection was successfully | ||
| 456 | established and 0 or -1 if the connection failed. | ||
| 457 | .Sh EXAMPLES | ||
| 458 | This example connects to a webserver on the local host and attempts | ||
| 459 | to retrieve a page and copy the result to standard output. | ||
| 460 | .Bd -literal -offset 2n | ||
| 461 | BIO *cbio, *out; | ||
| 462 | int len; | ||
| 463 | char tmpbuf[1024]; | ||
| 464 | |||
| 465 | ERR_load_crypto_strings(); | ||
| 466 | cbio = BIO_new_connect("localhost:http"); | ||
| 467 | out = BIO_new_fp(stdout, BIO_NOCLOSE); | ||
| 468 | if (BIO_do_connect(cbio) <= 0) { | ||
| 469 | fprintf(stderr, "Error connecting to server\en"); | ||
| 470 | ERR_print_errors_fp(stderr); | ||
| 471 | /* whatever ... */ | ||
| 472 | } | ||
| 473 | BIO_puts(cbio, "GET / HTTP/1.0\en\en"); | ||
| 474 | for(;;) { | ||
| 475 | len = BIO_read(cbio, tmpbuf, 1024); | ||
| 476 | if (len <= 0) | ||
| 477 | break; | ||
| 478 | BIO_write(out, tmpbuf, len); | ||
| 479 | } | ||
| 480 | BIO_free(cbio); | ||
| 481 | BIO_free(out); | ||
| 482 | .Ed | ||
| 483 | .Sh SEE ALSO | ||
| 484 | .Xr BIO_new 3 | ||
| 485 | .Sh HISTORY | ||
| 486 | .Fn BIO_s_connect , | ||
| 487 | .Fn BIO_new_connect , | ||
| 488 | .Fn BIO_set_nbio , | ||
| 489 | and | ||
| 490 | .Fn BIO_do_connect | ||
| 491 | first appeared in SSLeay 0.8.0. | ||
| 492 | .Fn BIO_set_conn_hostname , | ||
| 493 | .Fn BIO_set_conn_port , | ||
| 494 | .Fn BIO_set_conn_ip , | ||
| 495 | .Fn BIO_set_conn_int_port , | ||
| 496 | .Fn BIO_get_conn_hostname , | ||
| 497 | .Fn BIO_get_conn_port , | ||
| 498 | .Fn BIO_get_conn_ip , | ||
| 499 | and | ||
| 500 | .Fn BIO_get_conn_int_port | ||
| 501 | first appeared in SSLeay 0.9.0. | ||
| 502 | All these functions have been available since | ||
| 503 | .Ox 2.4 . | ||
