流缓冲管理,
ustream_fd
跟uloop_fd
有什么不一样呢?ustream_fd
内部其实就是uloop_fd
,与fopen和open类似,fopen的内部也是open加上流缓冲管理。
struct ustream_fd {
struct ustream stream;
struct uloop_fd fd;
};
ustream相关的函数
void ustream_fd_init(struct ustream_fd *s, int fd)
void ustream_init_defaults(struct ustream *s)
void ustream_free(struct ustream *s)
ustream的应用在uhttpd的socket监听里面有使用到
bool uh_accept_client(int fd, bool tls)
{
static struct client *next_client;
struct client *cl;
unsigned int sl;
int sfd;
static int client_id = 0;
struct sockaddr_in6 addr;
if (!next_client)
next_client = calloc(1, sizeof(*next_client));