retroforth/interface/sockets.retro
crc 2deb870e60 interfaces: various updates
FossilOrigin-Name: 7a7f047431c56d94272e54fe7380ab427a76ef8b067fcdf1131bf5d0d0952d7f
2019-12-09 19:37:26 +00:00

28 lines
970 B
Text

This implements the Forth part of the socket I/O interface.
The sockets interface is low level, and very close to the
underlying BSD sockets model.
~~~
{{
'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---
:io:socket-operation identify @Sockets io:invoke ;
}}
:socket:gethostbyname (as-) #0 io:socket-operation ;
:socket:create (-n) #1 io:socket-operation ;
:socket:bind (sn-n) #2 io:socket-operation ;
:socket:listen (nn-nn) #3 io:socket-operation ;
:socket:accept (n-nn) #4 io:socket-operation ;
:socket:connect (n-nn) #5 io:socket-operation ;
:socket:send (sn-nn) #6 io:socket-operation ;
:socket:recv (ann-nn) #8 io:socket-operation ;
:socket:close (n-) #10 io:socket-operation ;
:socket:configure (ss-) #11 io:socket-operation ;
~~~