BIO socket -- brief introduction

 

Well, it’s a little bit complicated and there are so little documents on socket BIO, so I will give more instruction and more sample codes.

First introduce some key points.

 

a)      There are three main kinds of BIO socket: BIO_s_socket, BIO_s_connect, and BIO_s_accept. You may regard the first one as a “raw” socket, the second one a client socket, and the last one a server socket. You may assign a fd(SOCKET) to them later.

b)      Fd, is just the Socket object. You may use BIO_get_fd() or BIO_set_fd() to get or set the socket object. And the socket object is stored in BIO.num.

c)      BIO.ptr pointing to a private struct that contain socket information such as address, state, blocking mode and so on. There are two kinds of struct: BIO_ACCEPT and BIO_CONNECT.

d)      You may use the three function to send or receive data.

    int BIO_puts(BIO *b, const char *in); // send string

    int BIO_write(BIO *b, const void *in, int inl); // send raw data

    int BIO_read(BIO *b, void *out, int outl); //receive data.

e)      It’s thread safe, you can pass the BIO pointer to one thread.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值