2019-06-30 17:11:55 +03:00
|
|
|
import net
|
|
|
|
|
2019-07-01 15:55:45 +03:00
|
|
|
fn test_socket() {
|
|
|
|
// server := net.listen(8080)
|
|
|
|
// println(server)
|
|
|
|
// client := net.dial('127.0.0.1', 8080)
|
|
|
|
// println(client)
|
|
|
|
// socket := server.accept()
|
|
|
|
// println(socket)
|
2019-07-02 18:25:21 +03:00
|
|
|
|
|
|
|
// message := 'Hello World'
|
|
|
|
// socket.send(message.cstr(), message.len)
|
|
|
|
// println('Sent: ' + message)
|
|
|
|
|
|
|
|
// bytes := client.recv(1024)
|
|
|
|
// println('Received: ' + tos(bytes, message.len))
|
|
|
|
|
2019-07-01 15:55:45 +03:00
|
|
|
// server.close()
|
|
|
|
// client.close()
|
|
|
|
// socket.close()
|
2019-06-30 17:11:55 +03:00
|
|
|
}
|