Manual Pages for UNIX Darwin command on man BIO_set_nbio
MyWebUniversity

Manual Pages for UNIX Darwin command on man BIO_set_nbio

BIOsconnect(3) OpenSSL BIOsconnect(3)

NAME

BIOsconnect, BIOsetconnhostname, BIOsetconnport, BIOsetconnip, BIOsetconnintport, BIOgetconnhostname, BIOgetconnport, BIOgetconnip, BIOgetconnintport,

BIOsetnbio, BIOdoconnect - connect BIO

SYNOPSIS

#include

BIOMETHOD * BIOsconnect(void); BIO *BIOnewconnect(char *name); long BIOsetconnhostname(BIO *b, char *name); long BIOsetconnport(BIO *b, char *port); long BIOsetconnip(BIO *b, char *ip); long BIOsetconnintport(BIO *b, char *port); char *BIOgetconnhostname(BIO *b); char *BIOgetconnport(BIO *b); char *BIOgetconnip(BIO *b, dummy); long BIOgetconnintport(BIO *b, int port); long BIOsetnbio(BIO *b, long n); int BIOdoconnect(BIO *b);

DESCRIPTION

BIOsconnect() returns the connect BIO method. This is a wrapper round the platform's TCP/IP socket connection routines. Using connect BIOs, TCP/IP connections can be made and data transferred using only BIO routines. In this way any platform specific operations are hidden by the BIO abstraction. Read and write operations on a connect BIO will perform I/O on the underlying connection. If no connection is established and the port and hostname (see below) is set up properly then a connection is established first. Connect BIOs support BIOputs() but not BIOgets(). If the close flag is set on a connect BIO then any active connection is shutdown and the socket closed when the BIO is freed. Calling BIOreset() on a connect BIO will close any active connection and reset the BIO into a state where it can connect to the same host again. BIOgetfd() places the underlying socket in cc if it is not NULL, it also returns the socket . If cc is not NULL it should be of type (int *). BIOsetconnhostname() uses the string nnaammee to set the hostname. The hostname can be an IP address. The hostname can also include the port in the form hostname:port . It is also acceptable to use the form "hostname/any/other/path" or "hostname:port/any/other/path". BIOsetconnport() sets the port to ppoorrtt. ppoorrtt can be the numerical form or a string such as "http". A string will be looked up first using getservbyname() on the host platform but if that fails a standard table of port names will be used. Currently the list is http, telnet, socks, https, ssl, ftp, gopher and wais. BIOsetconnip() sets the IP address to iipp using binary form, that is

four bytes specifying the IP address in big-endian form.

BIOsetconnintport() sets the port using ppoorrtt. ppoorrtt should be of type (int *). BIOgetconnhostname() returns the hostname of the connect BIO or NULL if the BIO is initialized but no hostname is set. This return value is an internal pointer which should not be modified. BIOgetconnport() returns the port as a string. BIOgetconnip() returns the IP address in binary form. BIOgetconnintport() returns the port as an int. BIOsetnbio() sets the non blocking I/O flag to nn. If nn is zero then blocking I/O is set. If nn is 1 then non blocking I/O is set. Blocking I/O is the default. The call to BIOsetnbio() should be made before the connection is established because non blocking I/O is set during the connect process. BIOnewconnect() combines BIOnew() and BIOsetconnhostname() into a single call: that is it creates a new connect BIO with nnaammee. BIOdoconnect() attempts to connect the supplied BIO. It returns 1 if the connection was established successfully. A zero or negative value is returned if the connection could not be established, the call BIOshouldretry() should be used for non blocking connect BIOs to determine if the call should be retried. NNOOTTEESS If blocking I/O is set then a non positive return value from any I/O call is caused by an error condition, although a zero return will normally mean that the connection was closed. If the port name is supplied as part of the host name then this will override any value set with BIOsetconnport(). This may be undesirable if the application does not wish to allow connection to arbitrary ports. This can be avoided by checking for the presence of the ':' character in the passed hostname and either indicating an error or truncating the string at that point. The values returned by BIOgetconnhostname(), BIOgetconnport(), BIOgetconnip() and BIOgetconnintport() are updated when a connection attempt is made. Before any connection attempt the values returned are those set by the application itself. Applications do not have to call BIOdoconnect() but may wish to do so to separate the connection process from other I/O processing. If non blocking I/O is set then retries will be requested as appropriate. It addition to BIOshouldread() and BIOshouldwrite() it is also possible for BIOshouldiospecial() to be true during the initial connection process with the reason BIORRCONNECT. If this is returned then this is an indication that a connection attempt would block, the application should then take appropriate action to wait until the underlying socket has connected and retry the call. BIOsetconnhostname(), BIOsetconnport(), BIOsetconnip(), BIOsetconnintport(), BIOgetconnhostname(), BIOgetconnport(), BIOgetconnip(), BIOgetconnintport(), BIOsetnbio() and BIOdoconnect() are macros.

RETURN VALUES

BIOsconnect() returns the connect BIO method.

BIOgetfd() returns the socket or -1 if the BIO has not been

initialized. BIOsetconnhostname(), BIOsetconnport(), BIOsetconnip() and BIOsetconnintport() always return 1. BIOgetconnhostname() returns the connected hostname or NULL is none was set. BIOgetconnport() returns a string representing the connected port or NULL if not set. BIOgetconnip() returns a pointer to the connected IP address in binary form or all zeros if not set. BIOgetconnintport() returns the connected port or 0 if none was set. BIOsetnbio() always returns 1. BIOdoconnect() returns 1 if the connection was successfully

established and 0 or -1 if the connection failed.

EEXXAAMMPPLLEE This is example connects to a webserver on the local host and attempts to retrieve a page and copy the result to standard output. BIO *cbio, *out; int len; char tmpbuf[1024]; ERRloadcryptostrings(); cbio = BIOnewconnect("localhost:http"); out = BIOnewfp(stdout, BIONOCLOSE); if(BIOdoconnect(cbio) <= 0) { fprintf(stderr, "Error connecting to server\n"); ERRprinterrorsfp(stderr); /* whatever ... */ } BIOputs(cbio, "GET / HTTP/1.0\n\n"); for(;;) { len = BIOread(cbio, tmpbuf, 1024); if(len <= 0) break; BIOwrite(out, tmpbuf, len); } BIOfree(cbio); BIOfree(out);

SEE ALSO

TBA

0.9.7l 2000-10-19 BIOsconnect(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™