use stream : io.Stream;
handle: Handle;
- close :: socket_close
- bind :: socket_bind
- listen :: socket_listen
- accept :: socket_accept
- connect :: socket_connect
- send :: socket_send
- sendall :: socket_sendall
- recv :: socket_recv
+ close :: socket_close
+ bind :: socket_bind
+ listen :: socket_listen
+ accept :: socket_accept
+ connect :: socket_connect
+ send :: socket_send
+ sendall :: socket_sendall
+ recv :: socket_recv
+ recv_into :: socket_recv_into
}
-#foreign "onyx_runtime" {
- __net_create_socket :: (out_handle: ^Socket.Handle, domain: SocketDomain, type: SocketType) -> SocketError ---
- __net_close_socket :: (handle: Socket.Handle) -> void ---
- __net_bind :: (handle: Socket.Handle, port: u16) -> bool ---
- __net_listen :: (handle: Socket.Handle, backlog: i32) -> void ---
- __net_accept :: (handle: Socket.Handle) -> Socket.Handle --- // This should also return the address, but in what format?
- __net_connect :: (handle: Socket.Handle, host: str, port: u16) -> SocketError ---
- __net_send :: (handle: Socket.Handle, data: [] u8) -> u32 ---
- __net_recv :: (handle: Socket.Handle, data: [] u8) -> u32 ---
-}
-
-#local {
- SocketError :: enum {
- None :: 0x00;
- BadSettings :: 0x01;
- NoHost :: 0x02;
- ConnectFailed :: 0x03;
- }
+SocketError :: enum {
+ None :: 0x00;
+ BadSettings :: 0x01;
+ NoHost :: 0x02;
+ ConnectFailed :: 0x03;
+}
- SocketDomain :: enum {
- Unix :: 0x00;
- Inet :: 0x01;
- Inet6 :: 0x02;
- }
+SocketDomain :: enum {
+ Unix :: 0x00;
+ Inet :: 0x01;
+ Inet6 :: 0x02;
+}
- SocketType :: enum {
- Stream :: 0x00;
- Dgram :: 0x01;
- }
+SocketType :: enum {
+ Stream :: 0x00;
+ Dgram :: 0x01;
+}
+
+SocketSetting :: enum {
}
socket_create :: (domain: SocketDomain, type: SocketType) -> (Socket, SocketError) {
s.vtable = null;
}
+socket_setting :: (s: ^Socket, setting: SocketSetting, value: u32) {
+}
+
socket_connect :: (s: ^Socket, host: str, port: u16) -> SocketError {
return __net_connect(s.handle, host, port);
}
}
};
+#foreign "onyx_runtime" {
+ #package __net_create_socket :: (out_handle: ^Socket.Handle, domain: SocketDomain, type: SocketType) -> SocketError ---
+ #package __net_close_socket :: (handle: Socket.Handle) -> void ---
+ #package __net_bind :: (handle: Socket.Handle, port: u16) -> bool ---
+ #package __net_listen :: (handle: Socket.Handle, backlog: i32) -> void ---
+ #package __net_accept :: (handle: Socket.Handle) -> Socket.Handle --- // This should also return the address, but in what format?
+ #package __net_connect :: (handle: Socket.Handle, host: str, port: u16) -> SocketError ---
+ #package __net_send :: (handle: Socket.Handle, data: [] u8) -> u32 ---
+ #package __net_recv :: (handle: Socket.Handle, data: [] u8) -> u32 ---
+}
#operator >= macro (a, b: Socket.Handle) => cast(u32) a >= cast(u32) b;
#operator == macro (a, b: Socket.Handle) => cast(u32) a == cast(u32) b;