Net module
This module contains functions for setting up TCP network connections and sending and receiving data, and listening on TCP ports. If libgnutls was available when Kaya was configured, then TLS may be used to set up encrypted connections.
Data types
- Net::NetHandle - A network connection
- Net::Protocol - The protocol to use
Exceptions
- AcceptFailed - Failed to accept connection
- CantBind - Can't bind to port
- CantGetHost - Host not known
- CantInit - Initialisation failed
- CantListen - Can't listen on port
- CloseError - Close failed
- ConnectError - Connection failed
- NegativeLength - Negative Length
- NothingToReceive - No data to receive
- ProtocolNotSupported - Protocol not supported
- SelectError - Testing connection failed
- SendFailed - Sending data failed
Functions
- NetHandle accept(Int socket) - Accept a connection on a socket.
- Void closeConnection(NetHandle h) - Close a connection handle.
- Void closeSocket(Int x) - Close a socket.
- Bool connWaiting(Int socket,Int timeout=0) - Check for connections waiting on a socket.
- NetHandle connect(Protocol proto,String server,Int port,Bool usetls=false,[String] certfiles=[]) - Connect to a server
- String getHost(NetHandle h) - Get the host name from a connection handle.
- Int listen(Protocol proto,Int port,Int backlog) - Listen on a port.
- Bool microPending(NetHandle h,Int timeout=100) - Return whether data is waiting at a socket.
- String microRecv(NetHandle h,Int maxlen=-1,Int microtimeout=0) - Recieve data from a connection.
- Bool netInit() - Initialises networking libraries.
- Bool pending(NetHandle h,Int timeout=5) - Return whether data is waiting at a socket.
- String recv(NetHandle h,Int maxlen=-1,Int timeout=0) - Recieve data from a connection.
- Int recvByte(NetHandle h,Int timeout=0) - Recieve data from a connection.
- Binary recvBytes(NetHandle h,Int maxlen=1024,Int timeout=0) - Recieve binary data from a connection.
- Void send(NetHandle h,String d) - Send data across a connection.
- Void sendByte(NetHandle h,Int byte) - Send a single byte across a connection.
- Void sendBytes(NetHandle h,Binary d) - Send binary data across a connection.
- Void shutdown(NetHandle h) - Shutdown a network handle.
- Void startTLS(NetHandle h,[String] certfiles=[]) - Convert an existing connection to use TLS.
- Void waitFor(NetHandle h) - Block until there is some data available to read from the handle.