2021-02-11 17:51:12 +01:00
|
|
|
module unix
|
|
|
|
|
2021-05-22 09:53:19 +02:00
|
|
|
#include <sys/un.h>
|
|
|
|
|
2021-02-11 17:51:12 +01:00
|
|
|
// Select represents a select operation
|
|
|
|
enum Select {
|
|
|
|
read
|
|
|
|
write
|
|
|
|
except
|
|
|
|
}
|
|
|
|
|
|
|
|
// SocketType are the available sockets
|
2021-03-05 15:41:11 +01:00
|
|
|
// enum SocketType {
|
|
|
|
// dgram = C.SOCK_DGRAM
|
|
|
|
// stream = C.SOCK_STREAM
|
|
|
|
// seqpacket = C.SOCK_SEQPACKET
|
|
|
|
// }
|
2021-02-11 17:51:12 +01:00
|
|
|
|
|
|
|
struct C.sockaddr {
|
|
|
|
sa_family u16
|
|
|
|
}
|
|
|
|
|
2021-02-11 21:34:38 +01:00
|
|
|
const max_sun_path = 104
|
|
|
|
|
|
|
|
// 104 for macos, 108 for linux => use the minimum
|
|
|
|
|
2021-02-11 17:51:12 +01:00
|
|
|
struct C.sockaddr_un {
|
|
|
|
mut:
|
2021-02-12 00:11:49 +01:00
|
|
|
// sun_len byte // only on macos
|
2021-02-11 17:51:12 +01:00
|
|
|
sun_family int
|
2021-02-12 00:11:49 +01:00
|
|
|
sun_path [104]char // on linux that is 108
|
2021-02-11 17:51:12 +01: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 {
|
|
|
|
}
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.socket() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.setsockopt() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.htonl() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.htons() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.bind() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.listen() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.accept() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.getaddrinfo() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.connect() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.send() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.sendto() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.recv() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.recvfrom() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.shutdown() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.getpeername() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.inet_ntop(af int, src voidptr, dst charptr, dst_size int) charptr
|
2021-02-18 08:02:56 +01:00
|
|
|
|
|
|
|
fn C.WSAAddressToStringA() int
|
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.getsockname() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
|
|
|
// defined in builtin
|
|
|
|
// fn C.read() int
|
|
|
|
// fn C.close() int
|
|
|
|
|
|
|
|
fn C.ioctlsocket() int
|
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.fcntl() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.@select() int
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.FD_ZERO()
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.FD_SET()
|
2021-02-18 08:02:56 +01:00
|
|
|
|
2021-03-05 15:41:11 +01:00
|
|
|
// fn C.FD_ISSET() bool
|
2021-02-18 08:02:56 +01:00
|
|
|
|
|
|
|
[typedef]
|
|
|
|
struct C.fd_set {}
|