retroforth/example/socket-server.retro
crc 848ba7303b use .retro instead of .forth in examples
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
2019-08-20 18:46:40 +00:00

31 lines
448 B
Text

Get a socket.
~~~
socket:create 'Sock var<n>
~~~
Bind to port 9998.
~~~
'9998 @Sock socket:bind drop-pair
~~~
Prepare to listen for connections.
~~~
#3 @Sock socket:listen drop-pair
~~~
Serve the user some data. This will repeat 5 times, then end.
~~~
#5 [ @Sock socket:accept (discard_error_code: drop )
'Hello_from_RETRO\n s:format swap [ socket:send drop-pair ] sip socket:close
] times
~~~
Clean up.
~~~
@Sock socket:close
~~~