let native := requireModule "WIN32/WINSOCKXYZ.5D" in let FFI := requireModule "FFI" in let List := requireModule "List" in let Tuple := requireModule "Tuple" in let IO := requireModule "IO" in let (;) := IO.(;) in let return! := IO.return! in let Composition := requireModule "Composition" in let rem := Composition.rem in let packRecord := FFI.packRecord in let unpackRecord := FFI.unpackRecord in let allocateRecord! := FFI.allocateRecord! in let head := List.head in let tail := List.tail in let (,) := Tuple.(,) in let sockaddrInFormat := ">IHxxI" in let sockaddrInSize := 12 in let packSockaddr := (\value let family := head value in let port := head (tail value) in let addr := head (tail (tail value)) in packRecord sockaddrInFormat [family port addr] ) in let unpackSockaddr := (\buf let result := unpackRecord sockaddrInFormat buf in rem "family port addr" result ) in let connect! := (\FD \addr native.connect! FD (packSockaddr addr) sockaddrInSize ) in let bind! := (\FD \addr native.bind! FD (packSockaddr addr) sockaddrInSize ) in let accept! := (\FD allocateRecord! sockaddrInFormat ;\addr native.accept! FD addr sockaddrInSize ;\status return! (status, addr) ) in (requireModule "Composition").dispatch1 [ ('socket!, native.socket!) ('bind!, bind!) ('listen!, native.listen!) ('accept!, accept!) ('connect!, connect!) ('send!, native.send!) ('recv!, native.recv!) ('setsockopt!, native.setsockopt!) ('shutdown!, native.shutdown!) ('afINET, (native.Constants.afINET)) ('afINET6, native.Constants.afINET6) ('sockStream, native.Constants.sockStream) ('sockDgram, native.Constants.sockDgram) ('sockSeqpacket, native.Constants.sockSeqpacket) ('sockRaw, native.Constants.sockRaw) ('shutRd, native.Constants.shutRd) ('shutWr, native.Constants.shutWr) ('shutRdwr, native.Constants.shutRdwr) ('sockRaw, native.Constants.sockRaw) ('packSockaddr, packSockaddr) ('unpackSockaddr, unpackSockaddr) ]