2020-09-16 21:07:06 +02:00
|
|
|
# Sockets
|
2019-06-06 19:15:52 +02:00
|
|
|
|
2020-09-16 21:07:06 +02:00
|
|
|
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.
|
2019-06-06 19:15:52 +02:00
|
|
|
|
2019-06-05 22:33:09 +02:00
|
|
|
~~~
|
|
|
|
{{
|
2019-12-09 20:37:26 +01:00
|
|
|
'Sockets var
|
2019-06-05 22:33:09 +02:00
|
|
|
:identify
|
2019-12-09 20:37:26 +01:00
|
|
|
@Sockets n:zero? [
|
2019-06-05 22:33:09 +02:00
|
|
|
#7 io:scan-for dup n:negative?
|
|
|
|
[ drop 'IO_DEVICE_TYPE_0004_NOT_FOUND s:put nl ]
|
2019-12-09 20:37:26 +01:00
|
|
|
[ !Sockets ] choose ] if ;
|
2019-06-05 22:33:09 +02:00
|
|
|
---reveal---
|
2020-09-16 21:07:06 +02:00
|
|
|
:socket:operation identify @Sockets io:invoke ;
|
2019-06-05 22:33:09 +02:00
|
|
|
}}
|
|
|
|
|
2020-09-16 21:07:06 +02:00
|
|
|
: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 ;
|
2019-06-05 22:55:35 +02:00
|
|
|
~~~
|