1 : |
monnier |
409 |
(* sock-util-sig.sml
|
2 : |
|
|
*
|
3 : |
|
|
* COPYRIGHT (c) 1996 AT&T Research.
|
4 : |
|
|
*
|
5 : |
|
|
* Various utility functions for programming with sockets.
|
6 : |
|
|
*)
|
7 : |
|
|
|
8 : |
|
|
signature SOCK_UTIL =
|
9 : |
|
|
sig
|
10 : |
|
|
|
11 : |
jhr |
2981 |
(*** Commented out unti socket API is supported by new runtime
|
12 : |
monnier |
409 |
datatype port = PortNumber of int | ServName of string
|
13 : |
|
|
(* a port can be identified by number, or by the name of a service *)
|
14 : |
|
|
|
15 : |
|
|
datatype hostname = HostName of string | HostAddr of NetHostDB.in_addr
|
16 : |
|
|
|
17 : |
|
|
val scanAddr : (char, 'a) StringCvt.reader
|
18 : |
|
|
-> ({host : hostname, port : port option}, 'a) StringCvt.reader
|
19 : |
|
|
(* scan an address, which has the form
|
20 : |
|
|
* addr [ ":" port ]
|
21 : |
|
|
* where the addr may either be numeric or symbolic host name and the
|
22 : |
|
|
* port is either a service name or a decimal number. Legal host names
|
23 : |
|
|
* must begin with a letter, and may contain any alphanumeric character,
|
24 : |
|
|
* the minus sign (-) and period (.), where the period is used as a
|
25 : |
|
|
* domain separator.
|
26 : |
|
|
*)
|
27 : |
jhr |
967 |
val addrFromString : string -> {host : hostname, port : port option} option
|
28 : |
monnier |
409 |
|
29 : |
|
|
exception BadAddr of string
|
30 : |
|
|
|
31 : |
|
|
val resolveAddr : {host : hostname, port : port option}
|
32 : |
|
|
-> {host : string, addr : NetHostDB.in_addr, port : int option}
|
33 : |
|
|
(* Given a hostname and optional port, resolve them in the host
|
34 : |
|
|
* and service database. If either the host or service name is not
|
35 : |
|
|
* found, then BadAddr is raised.
|
36 : |
|
|
*)
|
37 : |
|
|
|
38 : |
|
|
type 'a stream_sock = ('a, Socket.active Socket.stream) Socket.sock
|
39 : |
|
|
|
40 : |
|
|
val connectINetStrm : {addr : NetHostDB.in_addr, port : int}
|
41 : |
|
|
-> INetSock.inet stream_sock
|
42 : |
|
|
(* establish a client-side connection to a INET domain stream socket *)
|
43 : |
|
|
|
44 : |
|
|
val recvVec : ('a stream_sock * int) -> Word8Vector.vector
|
45 : |
|
|
val recvStr : ('a stream_sock * int) -> string
|
46 : |
|
|
val sendVec : ('a stream_sock * Word8Vector.vector) -> unit
|
47 : |
|
|
val sendStr : ('a stream_sock * string) -> unit
|
48 : |
|
|
val sendArr : ('a stream_sock * Word8Array.array) -> unit
|
49 : |
jhr |
2981 |
***)
|
50 : |
monnier |
409 |
|
51 : |
|
|
end;
|