projects
/
rrq
/
rrqforth.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update
[rrq/rrqforth.git]
/
examples
/
uenventlog.f
diff --git
a/examples/uenventlog.f
b/examples/uenventlog.f
index ff69c487ced849d1df07e356cf5770319afaaaea..c2d13416a2951eb93b5b4079cc18a36d1fd9acde 100755
(executable)
--- a/
examples/uenventlog.f
+++ b/
examples/uenventlog.f
@@
-16,7
+16,11
@@
SYSTEM DEFINITIONS
;
: DIE" ( n " quoted" -- ; If v then print message and exit )
;
: DIE" ( n " quoted" -- ; If v then print message and exit )
- " ROT IF TELL NL EMIT EXIT THEN 2DROP
+ " ROT IF TELL NL EMIT 1 EXIT THEN 2DROP
+;
+
+: time ( -- s ; seconds since epoch )
+ 0 SYS_TIME
;
HEX 100 DECIMAL CONSTANT MSG_WAITALL
;
HEX 100 DECIMAL CONSTANT MSG_WAITALL
@@
-27,14
+31,6
@@
HEX 80002 DECIMAL CONSTANT SOCK_DGRAM|SOCK_CLOEXEC
VARIABLE RECV-BUFFER NL_MAX_PAYLOAD ALLOT
VARIABLE RECV-BUFFER NL_MAX_PAYLOAD ALLOT
-: PRINTMSG ( n -- ; print RECV-BUFFER message )
- ( n is message length when >0 but we only use text up to first NUL )
- DUP 0 >
- IF DROP RECV-BUFFER DUP STRLEN TELL NL EMIT
- ELSE S" ** Error: " TELL . NL EMIT
- THEN
-;
-
VARIABLE NL-SOCKADDR
( 0-1 .family ) AF_NETLINK W,
( 2-3 ??? ) 0 W,
VARIABLE NL-SOCKADDR
( 0-1 .family ) AF_NETLINK W,
( 2-3 ??? ) 0 W,
@@
-52,7
+48,10
@@
SYS_BIND DIE" Failed to bind"
: NL-LOOP
BEGIN
NL-SOCKET @ RECV-BUFFER NL_MAX_PAYLOAD MSG_WAITALL 0 0
: NL-LOOP
BEGIN
NL-SOCKET @ RECV-BUFFER NL_MAX_PAYLOAD MSG_WAITALL 0 0
- SYS_RECVFROM PRINTMSG
+ SYS_RECVFROM DUP 0 >
+ IF DROP time . SP EMIT RECV-BUFFER DUP STRLEN TELL NL EMIT
+ ELSE S" ** Error: " TELL . NL EMIT
+ THEN
AGAIN
;
AGAIN
;