net Module
accept
dict:socket1 dict:socket2 ⇒ dict:socket1
Makes dict:socket2 (server) accept a connection from dict:socket1 (client). Returns the client socket dict:socket1 from which it will be possible to receive data from.
close
dict:socket ⇒ ∅
Closes a previously-opened socket.
connect
dict:socket str int ⇒ dict:socket
Connects socket dict:socket to address str and port int.
listen
dict dict:socket1 ⇒ dict:socket2
Makes socket dict:socket1 listen to the specified address and port. dict can be empty or contain any of the following properties, used to specify the address and port to listen to respectively.
- address
- The address to listen to (default: 0.0.0.0).
- port
- The port to listen to (default: 80).
recv
dict:socket int ⇒ str
Waits to receive int characters from dict:socket and returns the resulting data str.
recv-line
dict:socket ⇒ str
Waits to receive a line of data from dict:socket and returns the resulting data str. "" is returned if dict:socket is disconnected.
send
dict:socket str ⇒ ∅
Sends str to the connected socket dict:socket.
socket
dict ⇒ dict:socket
Opens a new socket.
dict can be empty or contain any of the following properties, used to specify the domain, type and protocol of the socket respectively.
- domain
The socket domain. It can be set to one of the following values:
- ipv4 (default): Internet Protocol version 4.
- ipv6: Internet Protocol version 6.
- unix: local Unix file (not supported on Windows systems).
- type
The socket type. It can be set to one of the following values:
- stream (default): Reliable stream-oriented service or Stream Socket.
- dgram: Datagram service or Datagram Socket.
- raw: Raw protocols atop the network layer.
- seqpacket: Reliable sequenced packet service.
- protocol
The socket protocol. It can be set to one of the following values:
- tcp (default): Transmission Control Protocol.
- udp: User Datagram Protocol.
- ipv4: Internet Protocol version 4 (not supported on Windows systems).
- ipv6: Internet Protocol version 6 (not supported on Windows systems).
- raw: Raw IP Packets protocol (not supported on Windows systems).
- icmp: Internet Control Message Protocol (not supported on Windows systems).