init
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// import net
|
||||
import netio
|
||||
// import time
|
||||
import os
|
||||
|
||||
fn main() {
|
||||
listen_addr := netio.SocketAddr.ipv4([u8(127), 0, 0, 1]!, 1081)
|
||||
eprintln(listen_addr.family())
|
||||
|
||||
// eprintln(listen_addr)
|
||||
// mut socket := netio.Socket.new(netio.af_inet, .tcp, 0)!
|
||||
// socket.bind(listen_addr)!
|
||||
// socket.listen(10)!
|
||||
// println('Server started...')
|
||||
// for {
|
||||
// conn_fd := socket.accept()!.fd
|
||||
// mut sock := net.tcp_socket_from_handle_raw(conn_fd)
|
||||
// mut conn := net.TcpConn{
|
||||
// sock: sock
|
||||
// handle: conn_fd
|
||||
// read_timeout: 30 * time.second
|
||||
// write_timeout: 30 * time.second
|
||||
// }
|
||||
// read := conn.read_line()
|
||||
// println('Data read: ${read}')
|
||||
// net.close(conn_fd)!
|
||||
// }
|
||||
// socket.close()!
|
||||
|
||||
// hostname := dump(os.hostname()!)
|
||||
ai := netio.translate_addr(
|
||||
node: 'localhost'
|
||||
flags: C.AI_CANONNAME
|
||||
family: netio.af_inet
|
||||
sock_type: netio.sock_stream
|
||||
)!
|
||||
dump(ai.len)
|
||||
for a in ai {
|
||||
println(a)
|
||||
// println('Protocol: ' + netio.protocol_by_number(a.protocol)!.name)
|
||||
// println('Address: ' + a.addr.str())
|
||||
// println('Canonical name: ' + a.canonical)
|
||||
// println('---')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user