Last active
September 30, 2019 16:46
-
-
Save michaelballantyne/1aeb9c56d56915e49d1eebe5d49ca466 to your computer and use it in GitHub Desktop.
close-output-port errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(match-define (list pout pin id perr f) (process "exit")) | |
(with-handlers ([exn:fail? (lambda (e) (printf "error in write: \n~a\n" e) (void))]) | |
(write-bytes #"foo" pin) | |
(flush-output pin) | |
(sleep 0.1) | |
(write-bytes #"bar" pin) | |
(flush-output pin)) | |
(with-handlers ([exn:fail? (lambda (e) (printf "error in close: \n~a\n" e) (void))]) | |
(close-output-port pin)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (server) | |
(define l (tcp-listen 8000)) | |
(define-values (in out) (tcp-accept l)) | |
(tcp-close l) | |
(close-input-port in) | |
(close-output-port out)) | |
(define (client) | |
(define-values (in out) (tcp-connect "127.0.0.1" 8000)) | |
(with-handlers ([exn:fail? (lambda (e) (printf "error in write: \n~a\n" e) (void))]) | |
(write-bytes #"foo" out) | |
(flush-output out) | |
(sleep 0.1) | |
(write-bytes #"bar" out) | |
(flush-output out)) | |
(with-handlers ([exn:fail? (lambda (e) (printf "error in close: \n~a\n" e) (void))]) | |
(close-output-port out))) | |
(define t (thread server)) | |
(sleep 0.1) | |
(client) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment