WebSocket 开发库 Wslay

码农软件 · 软件分类 · WebSocket开发包 · 2019-04-17 18:28:03

软件介绍

Wslay 是一个用 C 语言实现的 WebSocket 开发库。实现了 RFC 6455 中描述的第 13 版本的协议。提供了基于事件的 API 和基于帧的底层 API。特别适合非堵塞的 reactor 模式风格应用。可在不同的事件中设置回调。Wslay 只支持 WebSocket 协议的数据传输部分,不执行 HTTP 的握手过程。

示例代码:

ssize_t send_callback(wslay_event_context_ptr ctx,
                      const uint8_t *data, size_t len, void *user_data)
{
  struct Session *session = (struct Session*)user_data;
  ssize_t r;

  int sflags = 0;
#ifdef MSG_MORE
  if(flags & WSLAY_MSG_MORE) {
    sflags |= MSG_MORE;
  }
#endif // MSG_MORE
  while((r = send(session->fd, data, len, sflags)) == -1 && errno == EINTR);
  if(r == -1) {
    if(errno == EAGAIN || errno == EWOULDBLOCK) {
      wslay_event_set_error(ctx, WSLAY_ERR_WOULDBLOCK);
    } else {
      wslay_event_set_error(ctx, WSLAY_ERR_CALLBACK_FAILURE);
    }
  }
  return r;
}

本文地址:https://codercto.com/soft/d/3798.html

Microformats

Microformats

John Allsopp / friends of ED / March 26, 2007 / $34.99

In this book, noted web developer and long time WaSP member John Allsop teaches all you need to know about the technology: what Microformats are currently available and how to use them; the general pr......一起来看看 《Microformats》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试