Sortix main manual
This manual documents Sortix main. You can instead view this document in the latest official manual.
NAME
BIO_s_accept, BIO_set_accept_port, BIO_get_accept_port, BIO_new_accept, BIO_set_nbio_accept, BIO_set_accept_bios, BIO_set_bind_mode, BIO_get_bind_mode, BIO_do_accept — accept BIOSYNOPSIS
#include <openssl/bio.h>BIO_s_accept(void);
BIO_set_accept_port(BIO *b, char *name);
BIO_get_accept_port(BIO *b);
BIO_new_accept(const char *host_port);
BIO_set_nbio_accept(BIO *b, int n);
BIO_set_accept_bios(BIO *b, char *bio);
BIO_set_bind_mode(BIO *b, long mode);
BIO_get_bind_mode(BIO *b, long dummy);
#define BIO_BIND_REUSEADDR_IF_UNUSED 1
#define BIO_BIND_REUSEADDR 2
BIO_do_accept(BIO *b);
DESCRIPTION
BIO_s_accept() returns the accept BIO method. This is a wrapper round the platform's TCP/IP socket accept(2) routines.NOTES
When an accept BIO is at the end of a chain, it will await an incoming connection before processing I/O calls. When an accept BIO is not at the end of a chain, it passes I/O calls to the next BIO in the chain.connection = BIO_pop(accept);
RETURN VALUES
BIO_do_accept(), BIO_set_accept_port(), BIO_set_nbio_accept(), BIO_set_accept_bios(), and BIO_set_bind_mode() return 1 for success or 0 or -1 for failure.EXAMPLES
This example accepts two connections on port 4444, sends messages down each and finally closes both down.BIO *abio, *cbio, *cbio2; ERR_load_crypto_strings(); abio = BIO_new_accept("4444"); /* First call to BIO_accept() sets up accept BIO */ if (BIO_do_accept(abio) <= 0) { fprintf(stderr, "Error setting up accept\n"); ERR_print_errors_fp(stderr); exit(0); } /* Wait for incoming connection */ if (BIO_do_accept(abio) <= 0) { fprintf(stderr, "Error accepting connection\n"); ERR_print_errors_fp(stderr); exit(0); } fprintf(stderr, "Connection 1 established\n"); /* Retrieve BIO for connection */ cbio = BIO_pop(abio); BIO_puts(cbio, "Connection 1: Sending out Data on initial connection\n"); fprintf(stderr, "Sent out data on connection 1\n"); /* Wait for another connection */ if (BIO_do_accept(abio) <= 0) { fprintf(stderr, "Error accepting connection\n"); ERR_print_errors_fp(stderr); exit(0); } fprintf(stderr, "Connection 2 established\n"); /* Close accept BIO to refuse further connections */ cbio2 = BIO_pop(abio); BIO_free(abio); BIO_puts(cbio2, "Connection 2: Sending out Data on second\n"); fprintf(stderr, "Sent out data on connection 2\n"); BIO_puts(cbio, "Connection 1: Second connection established\n"); /* Close the two established connections */ BIO_free(cbio); BIO_free(cbio2);