## socket--premicrothread.api
# Compiled by:
#
src/lib/std/src/standard-core.sublibstipulate
package ci = mythryl_callable_c_library_interface; # mythryl_callable_c_library_interface is from
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg package os = winix_guts; # winix_guts is from
src/lib/std/src/posix/winix-guts.pkgherein
# We start with a version of this api that does not contain
# any of the non-blocking operations.
#
# This api is nowhere implemented as such.
# This api is included in:
#
#
src/lib/std/src/socket/synchronous-socket.api #
api Synchronous_Socket {
# Sockets are typeagnostic; the instantiation of the type variables
# provides a way to distinguish between different kinds of sockets.
#
Socket( A_af, A_sock_type );
Socket_Address( A_af );
# Witness types for the socket parameter:
#
Datagram;
Stream( A_mode );
Passive; # for passive streams
Active; # for active (connected) streams
# Address families
#
package af
:
api {
Address_Family
=
dns_host_lookup::Address_Family;
list: Void -> List ((String, Address_Family)); # list known address families
to_string: Address_Family -> String;
from_string: String -> Null_Or( Address_Family );
};
package typ # Socket types.
:
api {
eqtype Socket_Type;
stream: Socket_Type; # Stream sockets
datagram: Socket_Type; # Datagram sockets
list: Void -> List ((String, Socket_Type)); # list known socket types
to_string: Socket_Type -> String;
from_string: String -> Null_Or( Socket_Type );
};
# Socket control operations:
#
package ctl
:
api {
# get/set socket options
#
get_debug: Socket( A_af, A_sock_type ) -> Bool;
set_debug: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_reuseaddr: Socket( A_af, A_sock_type ) -> Bool;
set_reuseaddr: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_keepalive: Socket( A_af, A_sock_type ) -> Bool;
set_keepalive: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_dontroute: Socket( A_af, A_sock_type ) -> Bool;
set_dontroute: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_linger: Socket( A_af, A_sock_type ) -> Null_Or( time::Time );
set_linger: (Socket( A_af, A_sock_type ), Null_Or( time::Time )) -> Void;
get_broadcast: Socket( A_af, A_sock_type ) -> Bool;
set_broadcast: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_oobinline: Socket( A_af, A_sock_type ) -> Bool;
set_oobinline: (Socket( A_af, A_sock_type ), Bool) -> Void;
get_sndbuf: Socket( A_af, A_sock_type ) -> Int;
set_sndbuf: (Socket( A_af, A_sock_type ), Int) -> Void;
get_rcvbuf: Socket( A_af, A_sock_type ) -> Int;
set_rcvbuf: (Socket( A_af, A_sock_type ), Int) -> Void;
get_type: Socket( A_af, A_sock_type ) -> typ::Socket_Type;
get_error: Socket( A_af, A_sock_type ) -> Bool;
get_peer_name: Socket( A_af, A_sock_type ) -> Socket_Address( A_af );
get_sock_name: Socket( A_af, A_sock_type ) -> Socket_Address( A_af );
get_nread: Socket( A_af, A_sock_type ) -> Int;
get_atmark: Socket( A_af, Stream( Active ) ) -> Bool;
};
# Socket address operations:
#
same_address: (Socket_Address( A_af ), Socket_Address( A_af )) -> Bool;
family_of_address: Socket_Address( A_af ) -> af::Address_Family;
# Socket management:
#
bind: (Socket( A_af, A_sock_type ), Socket_Address( A_af )) -> Void;
listen: (Socket( A_af, Stream( Passive ) ), Int) -> Void;
accept: Socket( A_af, Stream( Passive ) )
-> (Socket( A_af, Stream( Active ) ), Socket_Address( A_af ));
connect: (Socket( A_af, A_sock_type ), Socket_Address( A_af )) -> Void;
close: Socket( A_af, A_sock_type ) -> Void;
Shutdown_Mode = NO_RECVS
| NO_SENDS | NO_RECVS_OR_SENDS;
shutdown: (Socket( A_af, Stream( A_mode ) ), Shutdown_Mode) -> Void;
Socket_Descriptor;
socket_descriptor: Socket( A_af, A_sock_type ) -> Socket_Descriptor;
same_descriptor: (Socket_Descriptor, Socket_Descriptor) -> Bool;
# See also the 'wait_for_io_opportunity' operation in
src/lib/std/src/winix/winix-io--premicrothread.api #
wait_for_io_opportunity
:
{ readable: List( Socket_Descriptor ),
writable: List( Socket_Descriptor ),
oobdable: List( Socket_Descriptor ),
timeout: Null_Or( time::Time ) }
->
{ readable: List( Socket_Descriptor ), # Sockets on which a read() will not block.
writable: List( Socket_Descriptor ), # Sockets on which a write() will not block.
oobdable: List( Socket_Descriptor ) # Sockets with out-of-band data available, (PTY packet-mode control status data).
};
# Deprecated synonym for above, mainly so that unix folks
# looking for 'select' in the function index will get led here:
#
select
:
{ readable: List( Socket_Descriptor ),
writable: List( Socket_Descriptor ),
oobdable: List( Socket_Descriptor ),
timeout: Null_Or( time::Time ) }
->
{ readable: List( Socket_Descriptor ), # Sockets on which a read() will not block.
writable: List( Socket_Descriptor ), # Sockets on which a write() will not block.
oobdable: List( Socket_Descriptor ) # Sockets with out-of-band data available, (PTY packet-mode control status data).
};
io_descriptor
:
Socket( A_af, A_sock_type )
->
os::io::Iod;
# Socket I/O option types
#
Out_Flags = { oob: Bool, don't_route: Bool };
In_Flags = { oob: Bool, peek: Bool };
# Socket output operations
#
send_vector : (Socket(A_af, Stream(Active)), vector_slice_of_one_byte_unts::Slice ) -> Int;
send_rw_vector : (Socket(X, Stream(Active)), rw_vector_slice_of_one_byte_unts::Slice ) -> Int;
send_vector' : (Socket(X, Stream(Active)), vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Int;
send_rw_vector' : (Socket(X, Stream(Active)), rw_vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Int;
send_vector_to : (Socket(X, Datagram), Socket_Address(X), vector_slice_of_one_byte_unts::Slice ) -> Void;
send_rw_vector_to : (Socket(X, Datagram), Socket_Address(X), rw_vector_slice_of_one_byte_unts::Slice ) -> Void;
send_vector_to' : (Socket(X, Datagram), Socket_Address(X), vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Void;
send_rw_vector_to' : (Socket(X, Datagram), Socket_Address(X), rw_vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Void;
# Socket input operations
#
receive_vector : (Socket(X, Stream(Active)), Int ) -> vector_of_one_byte_unts::Vector;
receive_rw_vector : (Socket(X, Stream(Active)), rw_vector_slice_of_one_byte_unts::Slice ) -> Int;
receive_vector' : (Socket(X, Stream(Active)), Int, In_Flags) -> vector_of_one_byte_unts::Vector;
receive_rw_vector' : (Socket(X, Stream(Active)), rw_vector_slice_of_one_byte_unts::Slice, In_Flags) -> Int;
receive_vector_from: (Socket(X, Datagram), Int) -> (vector_of_one_byte_unts::Vector, Socket_Address(Y));
receive_rw_vector_from: (Socket(X, Datagram), rw_vector_slice_of_one_byte_unts::Slice) -> (Int, Socket_Address(X));
receive_vector_from' : (Socket(X, Datagram), Int, In_Flags) -> (vector_of_one_byte_unts::Vector, Socket_Address(Y));
receive_rw_vector_from' : (Socket(X, Datagram), rw_vector_slice_of_one_byte_unts::Slice, In_Flags) -> (Int, Socket_Address(X));
};
# Finally we add non-blocking ops. # I think we should DROP THE NON-BLOCKING OPS ENTIRELY -- I see no point to them in the multithreaded-Mythryl context, and they are a mess. -- 2012-12-02 CrT
#
# This api is implemented in:
#
#
src/lib/std/src/socket/socket-guts.pkg #
api Socket__Premicrothread {
#
include api Synchronous_Socket; # See above.
#######################################################################
# Below stuff is intended only for one-time use during
# booting, to switch from direct to indirect syscalls: # For background see Note[1] in
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg Socket_Fd;
Internet_Address;
Raw_Address_Family;
Wy8Vector;
Wy8Array;
list_addr_families__syscall: Void -> List( ci::System_Constant );
set__list_addr_families__ref: ({ lib_name: String, fun_name: String, io_call: (Void -> List( ci::System_Constant )) } -> (Void -> List( ci::System_Constant ))) -> Void;
list_socket_types__syscall: Void -> List( ci::System_Constant );
set__list_socket_types__ref: ({ lib_name: String, fun_name: String, io_call: (Void -> List( ci::System_Constant )) } -> (Void -> List( ci::System_Constant ))) -> Void;
ctl_debug__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_debug__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_reuseaddr__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_reuseaddr__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_keepalive__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_keepalive__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_dontroute__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_dontroute__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_broadcast__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_broadcast__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_oobinline__syscall: (Socket_Fd, Null_Or(Bool)) -> Bool;
set__ctl_oobinline__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Bool)) -> Bool) } -> ((Socket_Fd, Null_Or(Bool)) -> Bool)) -> Void;
ctl_sndbuf__syscall: (Socket_Fd, Null_Or(Int )) -> Int;
set__ctl_sndbuf__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Int )) -> Int) } -> ((Socket_Fd, Null_Or(Int )) -> Int)) -> Void;
ctl_rcvbuf__syscall: (Socket_Fd, Null_Or(Int )) -> Int;
set__ctl_rcvbuf__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or(Int )) -> Int) } -> ((Socket_Fd, Null_Or(Int )) -> Int)) -> Void;
ctl_linger__syscall: (Socket_Fd, Null_Or( Null_Or(Int) )) -> Null_Or(Int);
set__ctl_linger__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Null_Or( Null_Or(Int) )) -> Null_Or(Int)) } -> ((Socket_Fd, Null_Or( Null_Or(Int) )) -> Null_Or(Int))) -> Void;
get_type__syscall: Socket_Fd -> ci::System_Constant;
set__get_type__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> ci::System_Constant) } -> (Socket_Fd -> ci::System_Constant)) -> Void;
get_error__syscall: Socket_Fd -> Bool;
set__get_error__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> Bool) } -> (Socket_Fd -> Bool)) -> Void;
get_peer_name__syscall: Socket_Fd -> Internet_Address;
set__get_peer_name__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> Internet_Address) } -> (Socket_Fd -> Internet_Address)) -> Void;
get_sock_name__syscall: Socket_Fd -> Internet_Address;
set__get_sock_name__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> Internet_Address) } -> (Socket_Fd -> Internet_Address)) -> Void;
get_nread__syscall: Socket_Fd -> Int;
set__get_nread__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> Int) } -> (Socket_Fd -> Int)) -> Void;
get_atmark__syscall: Socket_Fd -> Bool;
set__get_atmark__ref: ({ lib_name: String, fun_name: String, io_call: (Socket_Fd -> Bool) } -> (Socket_Fd -> Bool)) -> Void;
set_nonblockingio__syscall: (Socket_Fd, Bool) -> Void;
set__set_nonblockingio__ref: ({ lib_name: String, fun_name: String, io_call: ((Socket_Fd, Bool) -> Void) } -> ((Socket_Fd, Bool) -> Void)) -> Void;
get_address_family__syscall: Internet_Address -> Raw_Address_Family;
set__get_address_family__ref: ({ lib_name: String, fun_name: String, io_call: (Internet_Address -> Raw_Address_Family) } -> (Internet_Address -> Raw_Address_Family)) -> Void;
accept__syscall: Int -> (Int, Internet_Address);
set__accept__ref: ({ lib_name: String, fun_name: String, io_call: (Int -> (Int, Internet_Address)) } -> (Int -> (Int, Internet_Address))) -> Void;
bind__syscall: (Int, Internet_Address) -> Void;
set__bind__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Internet_Address) -> Void) } -> ((Int, Internet_Address) -> Void)) -> Void;
connect__syscall: (Int, Internet_Address) -> Void;
set__connect__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Internet_Address) -> Void) } -> ((Int, Internet_Address) -> Void)) -> Void;
listen__syscall: (Int, Int) -> Void;
set__listen__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Int) -> Void) } -> ((Int, Int) -> Void)) -> Void;
close__syscall: Int -> Void;
set__close__ref: ({ lib_name: String, fun_name: String, io_call: (Int -> Void) } -> (Int -> Void)) -> Void;
shutdown__syscall: (Int, Int) -> Void;
set__shutdown__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Int) -> Void) } -> ((Int, Int) -> Void)) -> Void;
send_v__syscall: (Int, Wy8Vector, Int, Int, Bool, Bool) -> Int;
set__send_v__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Vector, Int, Int, Bool, Bool) -> Int) } -> ((Int, Wy8Vector, Int, Int, Bool, Bool) -> Int)) -> Void;
send_a__syscall: (Int, Wy8Array, Int, Int, Bool, Bool) -> Int;
set__send_a__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Array, Int, Int, Bool, Bool) -> Int) } -> ((Int, Wy8Array, Int, Int, Bool, Bool) -> Int)) -> Void;
send_to_v__syscall: (Int, Wy8Vector, Int, Int, Bool, Bool, Internet_Address) -> Int;
set__send_to_v__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Vector, Int, Int, Bool, Bool, Internet_Address) -> Int) } -> ((Int, Wy8Vector, Int, Int, Bool, Bool, Internet_Address) -> Int)) -> Void;
send_to_a__syscall: (Int, Wy8Array, Int, Int, Bool, Bool, Internet_Address) -> Int;
set__send_to_a__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Array, Int, Int, Bool, Bool, Internet_Address) -> Int) } -> ((Int, Wy8Array, Int, Int, Bool, Bool, Internet_Address) -> Int)) -> Void;
recv_v__syscall: (Int, Int, Bool, Bool) -> Wy8Vector;
set__recv_v__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Int, Bool, Bool) -> Wy8Vector) } -> ((Int, Int, Bool, Bool) -> Wy8Vector)) -> Void;
recv_a__syscall: (Int, Wy8Array, Int, Int, Bool, Bool) -> Int;
set__recv_a__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Array, Int, Int, Bool, Bool) -> Int) } -> ((Int, Wy8Array, Int, Int, Bool, Bool) -> Int)) -> Void;
recv_from_v__syscall: (Int, Int, Bool, Bool) -> (Wy8Vector, Internet_Address);
set__recv_from_v__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Int, Bool, Bool) -> (Wy8Vector, Internet_Address)) } -> ((Int, Int, Bool, Bool) -> (Wy8Vector, Internet_Address))) -> Void;
recv_from_a__syscall: (Int, Wy8Array, Int, Int, Bool, Bool) -> (Int, Internet_Address);
set__recv_from_a__ref: ({ lib_name: String, fun_name: String, io_call: ((Int, Wy8Array, Int, Int, Bool, Bool) -> (Int, Internet_Address)) } -> ((Int, Wy8Array, Int, Int, Bool, Bool) -> (Int, Internet_Address))) -> Void;
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.