2020-08-21 00:01:37 +03:00
|
|
|
module net
|
|
|
|
|
|
|
|
// Select represents a select operation
|
|
|
|
enum Select {
|
2021-02-09 01:48:23 +03:00
|
|
|
read
|
|
|
|
write
|
|
|
|
except
|
2020-08-21 00:01:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// SocketType are the available sockets
|
|
|
|
pub enum SocketType {
|
|
|
|
udp = C.SOCK_DGRAM
|
|
|
|
tcp = C.SOCK_STREAM
|
|
|
|
}
|
|
|
|
|
|
|
|
// SocketFamily are the available address families
|
|
|
|
pub enum SocketFamily {
|
2021-02-09 01:48:23 +03:00
|
|
|
inet = C.AF_INET
|
2020-08-21 00:01:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct C.in_addr {
|
|
|
|
mut:
|
|
|
|
s_addr int
|
|
|
|
}
|
|
|
|
|
|
|
|
struct C.sockaddr {
|
2020-11-15 23:54:47 +03:00
|
|
|
sa_family u16
|
2020-08-21 00:01:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct C.sockaddr_in {
|
|
|
|
mut:
|
|
|
|
sin_family int
|
|
|
|
sin_port int
|
|
|
|
sin_addr C.in_addr
|
|
|
|
}
|
|
|
|
|
2021-02-09 01:48:23 +03:00
|
|
|
struct C.sockaddr_un {
|
|
|
|
mut:
|
|
|
|
sun_family int
|
|
|
|
sun_path charptr
|
|
|
|
}
|
2020-08-21 00:01:37 +03:00
|
|
|
|
|
|
|
struct C.addrinfo {
|
|
|
|
mut:
|
|
|
|
ai_family int
|
|
|
|
ai_socktype int
|
|
|
|
ai_flags int
|
|
|
|
ai_protocol int
|
|
|
|
ai_addrlen int
|
|
|
|
ai_addr voidptr
|
|
|
|
ai_canonname voidptr
|
|
|
|
ai_next voidptr
|
|
|
|
}
|
|
|
|
|
|
|
|
struct C.sockaddr_storage {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn C.socket() int
|
|
|
|
|
|
|
|
fn C.setsockopt() int
|
|
|
|
|
|
|
|
fn C.htonl() int
|
|
|
|
|
|
|
|
fn C.htons() int
|
|
|
|
|
|
|
|
fn C.bind() int
|
|
|
|
|
|
|
|
fn C.listen() int
|
|
|
|
|
|
|
|
fn C.accept() int
|
|
|
|
|
|
|
|
fn C.getaddrinfo() int
|
|
|
|
|
|
|
|
fn C.connect() int
|
|
|
|
|
|
|
|
fn C.send() int
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.sendto() int
|
|
|
|
|
|
|
|
fn C.recv() int
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.recvfrom() int
|
|
|
|
|
|
|
|
fn C.shutdown() int
|
|
|
|
|
|
|
|
fn C.ntohs() int
|
|
|
|
|
2020-11-15 23:54:47 +03:00
|
|
|
fn C.getpeername() int
|
|
|
|
|
2020-11-03 11:06:47 +03:00
|
|
|
fn C.inet_ntop(af int, src voidptr, dst charptr, dst_size int) charptr
|
2020-08-21 00:01:37 +03:00
|
|
|
|
2020-11-15 23:54:47 +03:00
|
|
|
fn C.WSAAddressToStringA() int
|
2020-09-08 16:15:35 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.getsockname() int
|
|
|
|
|
|
|
|
// defined in builtin
|
|
|
|
// fn C.read() int
|
|
|
|
// fn C.close() int
|
|
|
|
|
|
|
|
fn C.ioctlsocket() int
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.fcntl() int
|
|
|
|
|
|
|
|
fn C.@select() int
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.FD_ZERO()
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.FD_SET()
|
2021-02-09 01:48:23 +03:00
|
|
|
|
2020-08-21 00:01:37 +03:00
|
|
|
fn C.FD_ISSET() bool
|
|
|
|
|
|
|
|
[typedef]
|
2020-08-22 01:50:38 +03:00
|
|
|
pub struct C.fd_set {}
|