Sockets module
This module implements interprocess communication using sockets. This is useful for communicating between two processes started with fork using the socketPair function to create the sockets.
Sockets are represented by the Socket data type, and are generally similar to the NetHandle type in the Net module.
Data types
- Sockets::Socket - A socket
Exceptions
- SocketTimeout - Timeout while waiting for data
Functions
- Void close(Socket s) - Close a socket
- Void netToSocket(NetHandle net,Socket s) - Transfer data from network to socket
- Bool pending(Socket s,Int timeout=1000000) - Check for pending data on a socket
- String recv(Socket s,Int maxlen=-1,Int timeout=1000000) - Receive text data from a socket
- Int recvByte(Socket s,Int timeout=1000000) - Receive a single byte from a socket
- Binary recvBytes(Socket s,Int maxlen=1024,Int timeout=1000000) - Receive binary data from a socket
- Void send(Socket s,String msg) - Send data to a socket
- Void sendByte(Socket s,Int byte) - Send a single byte to a socket
- Void sendBytes(Socket s,Binary bindata) - Send binary data to a socket
- Pair<Socket, Socket> socketPair() - Create a joined pair of sockets
- Void socketToNet(Socket s,NetHandle net) - Transfer data from socket to network