Source src/silo:std.effects.tcp
1##! Tcp effect — TCP socket operations. 2##! 3##! Sub-effect of `Net`. Connection handles are integer identifiers 4##! today; a typed `TcpStream` record arrives later. 5 6:use 7 :open core Str Unit AnyInt Result 8 :open effects.net Net 9:end 10 11## TCP socket effect. Operations manipulate connection handles represented as 12## integer identifiers. 13:effect(pub) Tcp Net 14 ## Connects to a host:port pair and returns a connection handle. 15 .tcp-connect ( Str AnyInt -> (Result AnyInt Str) ) 16 ## Sends data on an existing TCP connection and returns bytes written. 17 .tcp-send ( AnyInt Str -> (Result AnyInt Str) ) 18 ## Reads up to the given number of bytes from a TCP connection. 19 .tcp-recv ( AnyInt AnyInt -> (Result Str Str) ) 20 ## Closes a TCP connection handle. 21 .tcp-close ( AnyInt -> (Result Unit Str) ) 22:end