retroforth/interface/sockets.retro

31 lines
1,005 B
Text
Raw Normal View History

# Sockets
This implements the Forth part of the socket I/O interface.
As with the file I/O device, the socket words are a thin
wrapper over the standard Unix socket functions. This means
that it is fairly low level.
~~~
{{
'Sockets var
:identify
@Sockets n:zero? [
#7 io:scan-for dup n:negative?
[ drop 'IO_DEVICE_TYPE_0004_NOT_FOUND s:put nl ]
[ !Sockets ] choose ] if ;
---reveal---
:socket:operation identify @Sockets io:invoke ;
}}
:socket:gethostbyname (as-) #0 socket:operation ;
:socket:create (-n) #1 socket:operation ;
:socket:bind (sn-n) #2 socket:operation ;
:socket:listen (nn-nn) #3 socket:operation ;
:socket:accept (n-nn) #4 socket:operation ;
:socket:connect (n-nn) #5 socket:operation ;
:socket:send (sn-nn) #6 socket:operation ;
:socket:recv (ann-nn) #8 socket:operation ;
:socket:close (n-) #10 socket:operation ;
:socket:configure (ss-) #11 socket:operation ;
~~~