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 /postcard.scm | |
parent | Add link to protocol in readme (diff) | |
download | postcard-main.tar.gz postcard-main.zip |
Diffstat (limited to 'postcard.scm')
-rw-r--r-- | postcard.scm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/postcard.scm b/postcard.scm index 5e54178..7c1eed6 100644 --- a/postcard.scm +++ b/postcard.scm | |||
@@ -1,13 +1,21 @@ | |||
1 | ;; client bit | 1 | ;; client bit |
2 | 2 | ||
3 | (import udp | 3 | (import srfi-13 |
4 | udp | ||
5 | utf8 | ||
4 | (chicken process-context)) | 6 | (chicken process-context)) |
5 | 7 | ||
6 | (define host "localhost") | 8 | (define host "95.216.214.66") |
7 | (define port 42069) | 9 | (define port 42069) |
8 | 10 | ||
9 | (define (main args) | 11 | (define (main args) |
10 | (define s (udp-open-socket)) | 12 | (define s (udp-open-socket)) |
11 | (udp-sendto s host port (apply string-append args))) | 13 | (udp-bind! s #f 0) ; automatically allocate one |
14 | (udp-sendto s host port (string-join args " ")) | ||
15 | (let loop ((s s)) | ||
16 | (receive (len str host port) (udp-recvfrom s 512) | ||
17 | (when (= len 0) | ||
18 | (loop s)) | ||
19 | (print host ":" port "\t" str)))) | ||
12 | 20 | ||
13 | (main (command-line-arguments)) | 21 | (main (command-line-arguments)) |