## synchronous-socket.api
# Compiled by:
#
src/lib/std/standard.lib#########################################
# The only difference between Synchronous_Socket
# and Synchronous_Socket from socket--premicrothread.api
# is that Socket has been renamed to Threadkit_Socket.
# This is a mess. :-( XXX BUGGO FIXME 2009-11-15 CrT
#########################################
stipulate
package dhl = dns_host_lookup; # dns_host_lookup is from
src/lib/std/src/socket/dns-host-lookup.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 never implemented as such.
# This api is 'include'-d in:
#
#
src/lib/std/src/socket/socket.api #
api Synchronous_Socket {
#
# Sockets are typeagnostic; the instantiation of the type variables
# provides a way to distinguish between different kinds of sockets.
#
Threadkit_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
=
dhl::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: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_debug: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_reuseaddr: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_reuseaddr: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_keepalive: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_keepalive: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_dontroute: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_dontroute: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_linger: Threadkit_Socket( A_af, A_sock_type ) -> Null_Or( time::Time );
set_linger: (Threadkit_Socket( A_af, A_sock_type ), Null_Or( time::Time )) -> Void;
get_broadcast: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_broadcast: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_oobinline: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
set_oobinline: (Threadkit_Socket( A_af, A_sock_type ), Bool) -> Void;
get_sndbuf: Threadkit_Socket( A_af, A_sock_type ) -> Int;
set_sndbuf: (Threadkit_Socket( A_af, A_sock_type ), Int) -> Void;
get_rcvbuf: Threadkit_Socket( A_af, A_sock_type ) -> Int;
set_rcvbuf: (Threadkit_Socket( A_af, A_sock_type ), Int) -> Void;
get_type: Threadkit_Socket( A_af, A_sock_type ) -> typ::Socket_Type;
get_error: Threadkit_Socket( A_af, A_sock_type ) -> Bool;
get_peer_name: Threadkit_Socket( A_af, A_sock_type ) -> Socket_Address( A_af );
get_sock_name: Threadkit_Socket( A_af, A_sock_type ) -> Socket_Address( A_af );
get_nread: Threadkit_Socket( A_af, A_sock_type ) -> Int;
get_atmark: Threadkit_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: (Threadkit_Socket( A_af, A_sock_type ), Socket_Address( A_af )) -> Void;
listen: (Threadkit_Socket( A_af, Stream( Passive ) ), Int) -> Void;
accept: Threadkit_Socket( A_af, Stream( Passive ) )
-> (Threadkit_Socket( A_af, Stream( Active ) ), Socket_Address( A_af ));
connect: (Threadkit_Socket( A_af, A_sock_type ), Socket_Address( A_af )) -> Void;
close: Threadkit_Socket( A_af, A_sock_type ) -> Void;
Shutdown_Mode = NO_RECVS
| NO_SENDS | NO_RECVS_OR_SENDS;
shutdown: (Threadkit_Socket( A_af, Stream( A_mode ) ), Shutdown_Mode) -> Void;
Socket_Descriptor;
socket_descriptor: Threadkit_Socket( A_af, A_sock_type ) -> Socket_Descriptor;
same_descriptor: (Socket_Descriptor, Socket_Descriptor) -> Bool;
# See also the 'poll' operation in
src/lib/std/src/winix/winix-io--premicrothread.api #
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
:
Threadkit_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 : (Threadkit_Socket( A_af, Stream( Active ) ), vector_slice_of_one_byte_unts::Slice ) -> Int;
send_rw_vector : (Threadkit_Socket( X, Stream( Active ) ), rw_vector_slice_of_one_byte_unts::Slice ) -> Int;
send_vector' : (Threadkit_Socket( X, Stream( Active ) ), vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Int;
send_rw_vector' : (Threadkit_Socket( X, Stream( Active ) ), rw_vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Int;
send_vector_to : (Threadkit_Socket( X, Datagram ), Socket_Address(X), vector_slice_of_one_byte_unts::Slice ) -> Void;
send_rw_vector_to : (Threadkit_Socket( X, Datagram ), Socket_Address(X), rw_vector_slice_of_one_byte_unts::Slice ) -> Void;
send_vector_to' : (Threadkit_Socket( X, Datagram ), Socket_Address(X), vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Void;
send_rw_vector_to' : (Threadkit_Socket( X, Datagram ), Socket_Address(X), rw_vector_slice_of_one_byte_unts::Slice, Out_Flags) -> Void;
# Socket input operations
#
receive_vector : (Threadkit_Socket( X, Stream( Active ) ), Int ) -> vector_of_one_byte_unts::Vector;
receive_rw_vector : (Threadkit_Socket( X, Stream( Active ) ), rw_vector_slice_of_one_byte_unts::Slice ) -> Int;
receive_vector' : (Threadkit_Socket( X, Stream( Active ) ), Int, In_Flags) -> vector_of_one_byte_unts::Vector;
receive_rw_vector' : (Threadkit_Socket( X, Stream( Active ) ), rw_vector_slice_of_one_byte_unts::Slice, In_Flags) -> Int;
receive_vector_from: (Threadkit_Socket( X, Datagram ), Int) -> (vector_of_one_byte_unts::Vector, Socket_Address(Y));
receive_rw_vector_from: (Threadkit_Socket( X, Datagram ), rw_vector_slice_of_one_byte_unts::Slice) -> (Int, Socket_Address(X));
receive_vector_from' : (Threadkit_Socket( X, Datagram ), Int, In_Flags) -> (vector_of_one_byte_unts::Vector, Socket_Address(Y));
receive_rw_vector_from' : (Threadkit_Socket( X, Datagram ), rw_vector_slice_of_one_byte_unts::Slice, In_Flags) -> (Int, Socket_Address(X));
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.