diff options
author | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2017-03-30 00:44:40 -0400 |
---|---|---|
committer | Ibrahim Mkusa <ibrahimmkusa@gmail.com> | 2017-03-30 00:44:40 -0400 |
commit | 49a079922ebe30ea76ca00fc874cfa4017b1a510 (patch) | |
tree | ba24dfb3f99783a622e0bc82378ed6119d219c0f | |
parent | bb0e49db30c0aad4c1cc4f0b1df0e2e33a5a70af (diff) |
reorganized some stuff, started experimenting with racket/gui
-rw-r--r-- | feasibility_analysis/gui/windows.rkt | 9 | ||||
-rw-r--r-- | feasibility_analysis/tcpevents/README.md | 1 | ||||
-rw-r--r-- | feasibility_analysis/tcpevents/server.rkt | 39 | ||||
-rw-r--r-- | feasibility_analysis/tcpvanilla/client.rkt (renamed from feasibility_analysis/client.rkt) | 0 | ||||
-rw-r--r-- | feasibility_analysis/tcpvanilla/client2.rkt (renamed from feasibility_analysis/client2.rkt) | 0 | ||||
-rw-r--r-- | feasibility_analysis/tcpvanilla/server.rkt (renamed from feasibility_analysis/server.rkt) | 0 | ||||
-rw-r--r-- | feasibility_analysis/tcpvanilla/tcptalk.rkt (renamed from feasibility_analysis/tcptalk.rkt) | 0 | ||||
-rw-r--r-- | feasibility_analysis/tcpvanilla/testdrive.md (renamed from feasibility_analysis/testdrive.md) | 0 |
8 files changed, 49 insertions, 0 deletions
diff --git a/feasibility_analysis/gui/windows.rkt b/feasibility_analysis/gui/windows.rkt new file mode 100644 index 0000000..4524673 --- /dev/null +++ b/feasibility_analysis/gui/windows.rkt @@ -0,0 +1,9 @@ +#lang racket + +(require racket/gui/base) + +;; Create a new window via the frame class +(define frame (new frame% [label "Example"])) + +;; Show frame(window) by calling it show method +(send frame show #t) ;; you call object methods via send diff --git a/feasibility_analysis/tcpevents/README.md b/feasibility_analysis/tcpevents/README.md new file mode 100644 index 0000000..7c3ec21 --- /dev/null +++ b/feasibility_analysis/tcpevents/README.md @@ -0,0 +1 @@ +TCP communication racket concepts of events. For more see the racket guide. diff --git a/feasibility_analysis/tcpevents/server.rkt b/feasibility_analysis/tcpevents/server.rkt new file mode 100644 index 0000000..4313bda --- /dev/null +++ b/feasibility_analysis/tcpevents/server.rkt @@ -0,0 +1,39 @@ +#lang racket + +(define (serve in-port out-port) + (let loop [] + (define evt (sync/timeout 2 + (read-line-evt in-port 'any) + (thread-receive-evt))) + (cond + [(not evt) + (displayln "Timed out, exiting") + (tcp-abandon-port in-port) + (tcp-abandon-port out-port)] + [(string? evt) + (fprintf out-port "~a~n" evt) + (flush-output out-port) + (loop)] + [else + (printf "Received a message in mailbox: ~a~n" + (thread-receive)) + (loop)]))) + +(define port-num 4321) +(define (start-server) + (define listener (tcp-listen port-num)) + (thread + (lambda () + (define-values [in-port out-port] (tcp-accept listener)) + (serve in-port out-port)))) + +(start-server) + +(define client-thread + (thread + (lambda () + (define-values [in-port out-port] (tcp-connect "localhost" port-num)) + (display "first\nsecond\nthird\n" out-port) + (flush-output out-port) + ; copy-port will block until EOF is read from in-port + (copy-port in-port (current-output-port))))) diff --git a/feasibility_analysis/client.rkt b/feasibility_analysis/tcpvanilla/client.rkt index 967d2b9..967d2b9 100644 --- a/feasibility_analysis/client.rkt +++ b/feasibility_analysis/tcpvanilla/client.rkt diff --git a/feasibility_analysis/client2.rkt b/feasibility_analysis/tcpvanilla/client2.rkt index 47e3052..47e3052 100644 --- a/feasibility_analysis/client2.rkt +++ b/feasibility_analysis/tcpvanilla/client2.rkt diff --git a/feasibility_analysis/server.rkt b/feasibility_analysis/tcpvanilla/server.rkt index bf72aff..bf72aff 100644 --- a/feasibility_analysis/server.rkt +++ b/feasibility_analysis/tcpvanilla/server.rkt diff --git a/feasibility_analysis/tcptalk.rkt b/feasibility_analysis/tcpvanilla/tcptalk.rkt index d069851..d069851 100644 --- a/feasibility_analysis/tcptalk.rkt +++ b/feasibility_analysis/tcpvanilla/tcptalk.rkt diff --git a/feasibility_analysis/testdrive.md b/feasibility_analysis/tcpvanilla/testdrive.md index b8e2883..b8e2883 100644 --- a/feasibility_analysis/testdrive.md +++ b/feasibility_analysis/tcpvanilla/testdrive.md |