TCP networking module for Quadrate.
quadpm install https://github.com/quadrate-lanuage/netuse net
fn main() {
// Server example
8080 net::listen! -> server
server net::accept! -> client
client 1024 net::receive! -> data -> n
client "Hello!" net::send! -> sent
client net::close
server net::close
// Client example
"localhost" 8080 net::connect! -> sock
sock "Hello server!" net::send! -> sent
sock 1024 net::receive! -> response -> n
sock net::close
}
listen(port:i64 -- socket:i64)!- Create server socket on portaccept(server:i64 -- client:i64)!- Accept incoming connection
connect(host:str port:i64 -- socket:i64)!- Connect to remote host
send(socket:i64 data:str -- bytes:i64)!- Send datareceive(socket:i64 max:i64 -- data:str bytes:i64)!- Receive data
shutdown(socket:i64 --)- Shutdown socket for writingclose(socket:i64 --)- Close socket
ErrListen(2) - Listen/bind failedErrAccept(3) - Accept failedErrConnect(4) - Connection failedErrSend(5) - Send failedErrReceive(6) - Receive failedErrInvalidArg(7) - Invalid argument
Apache-2.0