Giter Site home page Giter Site logo

wsock's Introduction

wsock

wsock is WebSocket library for libmill

The project is under construction!

Reference

*wsock wsocklisten(ipaddr addr, const char subprotocol, int backlog);

Start listening for connections from clients. Subprotocol is a comma-delimited list of supported subprotocols. Incoming connections that don't match any of the listed subprotocols will be silently dropped. If it is set to NULL, all connections will be accepted.

wsock wsockaccept(wsock s, int64_t deadline);

Accept new connection from a client.

**wsock wsockconnect(ipaddr addr, const char subprotocol, const char url, int64_t deadline);

Connect to a server. Subprotocol is a comma-delimited list of supported subprotocols. Put preferred protocols before less preferred ones. Server will choose one of the subprotocols -- to find out which one, use wsocksubprotocol() function. Setting subprotocol to NULL means that the server is free to choose any subprotocol.

*const char wsockurl(wsock s);

After accepting a connection, you can retrieve the URL requested by peer using this function.

*const char wsocksubprotocol(wsock s);

Get subprotocol the socket is using. If you've specified multiple subprotocols with wsocklisten() or wsockconnect(), this function lets you know which one of them was chosen to be used.

*size_t wsocksend(wsock s, const void msg, size_t len, int64_t deadline);

Send a message to the peer.

*size_t wsockrecv(wsock s, void msg, size_t len, int64_t deadline);

Receive a message from the peer.

void wsockping(wsock s, int64_t deadline);

Send ping to the peer. Peer replies with pong, which will cause wsockrecv() to exit with errno set to EAGAIN.

void wsockpong(wsock s, int64_t deadline);

Send pong to the peer. It can be used to implement unsolicited one-way heartbeats.

void wsockdone(wsock s, int64_t deadline);

Start the closing handshake. After calling this function you can't send any more messages, however, you can still receive pending messages from the peer.

void wsockclose(wsock s);

Close the connection without doing the closing handshake.

wsock's People

Contributors

sustrik avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.