More Unix I/O work

db4
Slava Pestov 2008-05-13 23:36:15 -05:00
parent 318f0875a1
commit 47f1c31261
2 changed files with 10 additions and 8 deletions

View File

@ -23,11 +23,8 @@ $nl
"Per-port native I/O protocol:"
{ $subsection init-handle }
{ $subsection (wait-to-read) }
"Additionally, the I/O backend must provide an implementation of the " { $link stream-flush } " and " { $link dispose } " generic words."
$nl
"Dummy ports which should be used to implement networking:"
{ $subsection server-port }
{ $subsection datagram-port } ;
{ $subsection (wait-to-write) }
"Additionally, the I/O backend must provide an implementation of the " { $link dispose } " generic word." ;
ABOUT: "io.ports"

View File

@ -73,6 +73,8 @@ M: ssl-handle drain
M: ssl ((client)) ( addrspec -- handle )
[ addrspec>> ((client)) <ssl-socket> ] with-destructors ;
M: ssl parse-sockaddr addrspec>> parse-sockaddr ;
: check-connect-response ( port r -- event )
check-response
{
@ -83,10 +85,13 @@ M: ssl ((client)) ( addrspec -- handle )
{ SSL_ERROR_SSL [ (ssl-error) ] }
} case ;
: do-ssl-connect ( port ssl -- )
: do-ssl-connect ( port ssl addrspec -- )
drop
2dup SSL_connect check-connect-response dup
[ nip wait-for-port ] [ 3drop ] if ;
M: ssl-handle (wait-to-connect)
[ file>> (wait-to-connect) ]
[ handle>> do-ssl-connect ] 2bi ;
addrspec>>
[ >r file>> r> (wait-to-connect) ]
[ >r handle>> r> do-ssl-connect ]
3bi ;