io.sockets.unix: refactor getsockopt into get-socket-option.
parent
b3fbafcf92
commit
cd90435588
|
@ -12,6 +12,11 @@ IN: io.sockets.unix
|
||||||
: socket-fd ( domain type protocol -- fd )
|
: socket-fd ( domain type protocol -- fd )
|
||||||
socket dup io-error <fd> init-fd |dispose ;
|
socket dup io-error <fd> init-fd |dispose ;
|
||||||
|
|
||||||
|
: get-socket-option ( fd level opt -- val )
|
||||||
|
[ handle-fd ] 2dip -1 int <ref> [
|
||||||
|
dup byte-length int <ref> getsockopt io-error
|
||||||
|
] keep int deref ;
|
||||||
|
|
||||||
: set-socket-option ( fd level opt -- )
|
: set-socket-option ( fd level opt -- )
|
||||||
[ handle-fd ] 2dip 1 int <ref> dup byte-length setsockopt io-error ;
|
[ handle-fd ] 2dip 1 int <ref> dup byte-length setsockopt io-error ;
|
||||||
|
|
||||||
|
@ -52,9 +57,7 @@ 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 SOL_SOCKET SO_ERROR
|
dup handle>> SOL_SOCKET SO_ERROR get-socket-option {
|
||||||
-1 int <ref> [ dup byte-length int <ref> getsockopt io-error ] keep int deref
|
|
||||||
{
|
|
||||||
{ 0 [ drop ] }
|
{ 0 [ drop ] }
|
||||||
{ EAGAIN [ wait-for-output ] }
|
{ EAGAIN [ wait-for-output ] }
|
||||||
{ EINTR [ wait-to-connect ] }
|
{ EINTR [ wait-to-connect ] }
|
||||||
|
|
Loading…
Reference in New Issue