io.sockets.unix: use getsockopt to check connect success.

db4
John Benediktsson 2016-03-13 13:08:26 -07:00
parent 5b3987a26f
commit 3fdbbe0fea
1 changed files with 8 additions and 7 deletions

View File

@ -52,13 +52,14 @@ DEFER: wait-to-connect
dup +output+ wait-for-port wait-to-connect ; inline dup +output+ wait-for-port wait-to-connect ; inline
: wait-to-connect ( port -- ) : wait-to-connect ( port -- )
dup handle>> handle-fd f 0 write 0 = [ drop ] [ dup handle>> handle-fd SOL_SOCKET SO_ERROR
errno { -1 int <ref> [ dup byte-length int <ref> getsockopt io-error ] keep int deref
{ EAGAIN [ wait-for-output ] } {
{ EINTR [ wait-to-connect ] } { 0 [ drop ] }
[ (throw-errno) ] { EAGAIN [ wait-for-output ] }
} case { EINTR [ wait-to-connect ] }
] if ; [ (throw-errno) ]
} case ;
M: object establish-connection M: object establish-connection
2dup 2dup