Feature #798

Add Irccd.Socket API

Added by David Demelier 8 months ago.

Status:NewStart date:04/16/2018
Priority:NormalDue date:
Assignee:David Demelier% Done:

0%

Category:libirccd-jsEstimated time:8.00 h
Target version:3.1.0
MFD after: Bookmark:@
MFD revision: Platform:
Branch:default

Description

Create an asynchronous Irccd.Socket API for communicating with internet and local sockets.

Server class

This object only have one function for accepting clients.

  • Server(options): create a server object,
  • Server.prototype.accept(handler): wait for a client and call the handler.

Socket class

  • Socket(type): create a socket,
  • Socket.prototype.connect(options, handler): connect to the given endpoint,
  • Socket.prototype.write(data, handler): write some data to the socket,
  • Socket.prototype.read(amount, handler): read some data from the socket,
  • Socket.prototype.readline(delimiter, handler): convenient handler that reads until a delimiter,
  • Socket.prototype.close(handler = null): close gracefully the socket.

Also available in: Atom PDF