diff options
author | Case Duckworth | 2023-04-11 11:32:19 -0500 |
---|---|---|
committer | Case Duckworth | 2023-04-11 11:32:19 -0500 |
commit | af43060e1c93d5a4050a4730fecb0803753c8535 (patch) | |
tree | 679fac0d0c2167b70f39001780092d40a67c1b21 /mailbox.scm | |
parent | Add link to protocol in readme (diff) | |
download | postcard-main.tar.gz postcard-main.zip |
Diffstat (limited to 'mailbox.scm')
-rw-r--r-- | mailbox.scm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mailbox.scm b/mailbox.scm index 948804c..82eaaad 100644 --- a/mailbox.scm +++ b/mailbox.scm | |||
@@ -1,6 +1,7 @@ | |||
1 | ;; server bit | 1 | ;; server bit |
2 | 2 | ||
3 | (import udp) | 3 | (import udp |
4 | utf8) | ||
4 | 5 | ||
5 | (define host "localhost") | 6 | (define host "localhost") |
6 | (define port 42069) | 7 | (define port 42069) |
@@ -9,11 +10,11 @@ | |||
9 | (define s (udp-open-socket)) | 10 | (define s (udp-open-socket)) |
10 | (udp-bind! s #f port) | 11 | (udp-bind! s #f port) |
11 | (let loop ((s s)) | 12 | (let loop ((s s)) |
12 | (receive (len str) (udp-recv s 512) | 13 | (receive (len str host port) (udp-recvfrom s 512) |
13 | (when (= len 0) | 14 | (when (= len 0) |
14 | (loop s)) | 15 | (loop s)) |
15 | (display str) | 16 | (print host ":" port "(" len ")\t" str) |
16 | (newline) | 17 | (udp-sendto s host port (string-append "received: " str)) |
17 | (loop s)))) | 18 | (loop s)))) |
18 | 19 | ||
19 | (main) | 20 | (main) |