Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / basis-library / net / socket.sig
CommitLineData
7f918cf1
CE
1signature SOCKET =
2 sig
3 type active
4 type dgram
5 type in_flags = {peek: bool, oob: bool}
6 type out_flags = {don't_route: bool, oob: bool}
7 type passive
8 datatype shutdown_mode =
9 NO_RECVS
10 | NO_SENDS
11 | NO_RECVS_OR_SENDS
12 type ('af,'sock_type) sock
13 type 'af sock_addr
14 type sock_desc
15 type 'mode stream
16
17 structure AF:
18 sig
19 type addr_family = NetHostDB.addr_family
20
21 val fromString: string -> addr_family option
22 val list: unit -> (string * addr_family) list
23 val toString: addr_family -> string
24 end
25
26 structure SOCK:
27 sig
28 eqtype sock_type
29
30 val dgram: sock_type
31 val fromString: string -> sock_type option
32 val list: unit -> (string * sock_type) list
33 val stream: sock_type
34 val toString: sock_type -> string
35 end
36
37 structure Ctl:
38 sig
39 val getATMARK: ('af, active stream) sock -> bool
40 val getBROADCAST: ('af, 'sock_type) sock -> bool
41 val getDEBUG: ('af, 'sock_type) sock -> bool
42 val getDONTROUTE: ('af, 'sock_type) sock -> bool
43 val getERROR: ('af, 'sock_type) sock -> bool
44 val getKEEPALIVE: ('af, 'sock_type) sock -> bool
45 val getLINGER: ('af, 'sock_type) sock -> Time.time option
46 val getNREAD: ('af, 'sock_type) sock -> int
47 val getOOBINLINE: ('af, 'sock_type) sock -> bool
48 val getPeerName: ('af, 'sock_type) sock -> 'af sock_addr
49 val getRCVBUF: ('af, 'sock_type) sock -> int
50 val getREUSEADDR: ('af, 'sock_type) sock -> bool
51 val getSNDBUF: ('af, 'sock_type) sock -> int
52 val getSockName: ('af, 'sock_type) sock -> 'af sock_addr
53 val getTYPE: ('af, 'sock_type) sock -> SOCK.sock_type
54 val setBROADCAST: ('af, 'sock_type) sock * bool -> unit
55 val setDEBUG: ('af, 'sock_type) sock * bool -> unit
56 val setDONTROUTE: ('af, 'sock_type) sock * bool -> unit
57 val setKEEPALIVE: ('af, 'sock_type) sock * bool -> unit
58 val setLINGER: ('af, 'sock_type) sock * Time.time option -> unit
59 val setOOBINLINE: ('af, 'sock_type) sock * bool -> unit
60 val setRCVBUF: ('af, 'sock_type) sock * int -> unit
61 val setREUSEADDR: ('af, 'sock_type) sock * bool -> unit
62 val setSNDBUF: ('af, 'sock_type) sock * int -> unit
63 end
64
65 val accept: ('af, passive stream) sock -> (('af, active stream) sock
66 * 'af sock_addr)
67 val acceptNB: ('af, passive stream) sock -> (('af, active stream) sock
68 * 'af sock_addr) option
69 val bind: ('af, 'sock_type) sock * 'af sock_addr -> unit
70 val close: ('af, 'sock_type) sock -> unit
71 val connect: ('af, 'sock_type) sock * 'af sock_addr -> unit
72 val connectNB: ('af, 'sock_type) sock * 'af sock_addr -> bool
73 val familyOfAddr: 'af sock_addr -> AF.addr_family
74 val ioDesc: ('af, 'sock_type) sock -> OS.IO.iodesc
75 val listen: ('af, passive stream) sock * int -> unit
76 val recvArr: ('af, active stream) sock * Word8ArraySlice.slice -> int
77 val recvArr': (('af, active stream) sock
78 * Word8ArraySlice.slice
79 * in_flags) -> int
80 val recvArrFrom: (('af, dgram) sock * Word8ArraySlice.slice
81 -> int * 'af sock_addr)
82 val recvArrFrom': (('af, dgram) sock * Word8ArraySlice.slice * in_flags
83 -> int * 'af sock_addr)
84 val recvArrFromNB: (('af, dgram) sock * Word8ArraySlice.slice
85 -> (int * 'af sock_addr) option)
86 val recvArrFromNB': (('af, dgram) sock * Word8ArraySlice.slice * in_flags
87 -> (int * 'af sock_addr) option)
88 val recvArrNB: (('af, active stream) sock
89 * Word8ArraySlice.slice) -> int option
90 val recvArrNB': (('af, active stream) sock
91 * Word8ArraySlice.slice
92 * in_flags) -> int option
93 val recvVec: ('af, active stream) sock * int -> Word8Vector.vector
94 val recvVec': (('af, active stream) sock * int * in_flags
95 -> Word8Vector.vector)
96 val recvVecFrom: (('af, dgram) sock * int
97 -> Word8Vector.vector * 'af sock_addr)
98 val recvVecFrom': (('af, dgram) sock * int * in_flags
99 -> Word8Vector.vector * 'af sock_addr)
100 val recvVecFromNB: (('af, dgram) sock * int
101 -> (Word8Vector.vector * 'af sock_addr) option)
102 val recvVecFromNB': (('af, dgram) sock * int * in_flags
103 -> (Word8Vector.vector * 'af sock_addr) option)
104 val recvVecNB: ('af, active stream) sock * int -> Word8Vector.vector option
105 val recvVecNB': (('af, active stream) sock * int * in_flags
106 -> Word8Vector.vector option)
107 val sameAddr: 'af sock_addr * 'af sock_addr -> bool
108 val sameDesc: sock_desc * sock_desc -> bool
109 val select: {exs: sock_desc list,
110 rds: sock_desc list,
111 timeout: Time.time option,
112 wrs: sock_desc list} -> {exs: sock_desc list,
113 rds: sock_desc list,
114 wrs: sock_desc list}
115 val sendArr: ('af, active stream) sock * Word8ArraySlice.slice -> int
116 val sendArr': (('af, active stream) sock
117 * Word8ArraySlice.slice
118 * out_flags) -> int
119 val sendArrNB: (('af, active stream) sock * Word8ArraySlice.slice
120 -> int option)
121 val sendArrNB': (('af, active stream) sock
122 * Word8ArraySlice.slice
123 * out_flags) -> int option
124 val sendArrTo: (('af, dgram) sock
125 * 'af sock_addr
126 * Word8ArraySlice.slice) -> unit
127 val sendArrTo': (('af, dgram) sock
128 * 'af sock_addr
129 * Word8ArraySlice.slice
130 * out_flags) -> unit
131 val sendArrToNB: (('af, dgram) sock
132 * 'af sock_addr
133 * Word8ArraySlice.slice) -> bool
134 val sendArrToNB': (('af, dgram) sock
135 * 'af sock_addr
136 * Word8ArraySlice.slice
137 * out_flags) -> bool
138 val sendVec: ('af, active stream) sock * Word8VectorSlice.slice -> int
139 val sendVec': (('af, active stream) sock
140 * Word8VectorSlice.slice
141 * out_flags) -> int
142 val sendVecNB: (('af, active stream) sock
143 * Word8VectorSlice.slice) -> int option
144 val sendVecNB': (('af, active stream) sock
145 * Word8VectorSlice.slice
146 * out_flags) -> int option
147 val sendVecTo: (('af, dgram) sock
148 * 'af sock_addr
149 * Word8VectorSlice.slice) -> unit
150 val sendVecTo': (('af, dgram) sock
151 * 'af sock_addr
152 * Word8VectorSlice.slice
153 * out_flags) -> unit
154 val sendVecToNB: (('af, dgram) sock
155 * 'af sock_addr
156 * Word8VectorSlice.slice) -> bool
157 val sendVecToNB': (('af, dgram) sock
158 * 'af sock_addr
159 * Word8VectorSlice.slice
160 * out_flags) -> bool
161 val shutdown: ('af, 'mode stream) sock * shutdown_mode -> unit
162 val sockDesc: ('af, 'sock_type) sock -> sock_desc
163 end
164
165signature SOCKET_EXTRA =
166 sig
167 include SOCKET
168 val fromRep : C_Sock.t -> ('af, 'sock_type) sock
169 val toRep : ('af, 'sock_type) sock -> C_Sock.t
170 val sockToWord: ('af, 'sock_type) sock -> SysWord.word
171 val wordToSock: SysWord.word -> ('af, 'sock_type) sock
172 val sockToFD: ('af, 'sock_type) sock -> Posix.FileSys.file_desc
173 val fdToSock: Posix.FileSys.file_desc -> ('af, 'sock_type) sock
174 type pre_sock_addr = Word8.word array
175 val unpackSockAddr: 'af sock_addr -> Word8.word vector
176 val newSockAddr: unit -> (pre_sock_addr * C_Socklen.t ref * (unit -> 'af sock_addr))
177
178 structure SOCKExtra:
179 sig
180 val toRep : SOCK.sock_type -> C_Sock.t
181 end
182
183 structure CtlExtra:
184 sig
185 type level = C_Int.int
186 type optname = C_Int.int
187
188 val getERROR: ('af, 'sock_type) sock -> (string * Posix.Error.syserror option) option
189 val getSockOptBool: level * optname -> ('af, 'sock_type) sock -> bool
190 val setSockOptBool: level * optname -> ('af, 'sock_type) sock * bool -> unit
191 end
192 end