Have you tried closing the ports? -- Matthias
On Sep 3, 2014, at 6:01 PM, Gilbert Martinez wrote: > I'm having issues reading the response from a TCP server. Specifically, any > attempt to read the input port does not terminate. I've used port->bytes, > read-byte, and read-line. In all cases the effect is the same. > > I thought that if there were no bytes available on an input port that the > read attempt would just return <eof>. Is this some kind of exclusivity > issue? Can I not read from the port until the connection with the server is > closed or something? > > My traffic monitor shows that the server is receiving the request and > responding (here is the exchange): > > Time Src. & Dst. Type Function Code Data > 908.875 10.10.10.10:49967<- TCP Req. 0x04 [0x000 - 0x027] > 00 01 00 00 00 06 0B 04 00 3B 00 03 > 908.905 10.10.10.10:49967-> TCP Resp. 0x04 [0x000 - 0x027] > 00 01 00 00 00 09 0B 04 06 00 00 00 00 00 00 > > Here is the code I am using to query: > > #lang racket > > > (define (hex-bytes->bytes hex-bytes-list) > (define (hex-byte->dec-byte hex-byte) > (string->number (string-append "#x" ((if (symbol? hex-byte) > symbol->string > number->string) > hex-byte)))) > (apply bytes (for/list ((hex-byte (in-list hex-bytes-list))) > (hex-byte->dec-byte hex-byte)))) > > (define-values (c-in c-out) (tcp-connect "10.10.10.11" 502)) > > (write-bytes (hex-bytes->bytes '(00 01 00 00 00 06 0B 04 00 3B 00 03)) c-out) > (flush-output c-out) > > > I run the code above and execute the following in the interactions pane: > > Welcome to DrRacket, version 6.1.0.5--2014-08-25(32ae3f8/a) [3m]. > Language: racket [custom]. > 12 > >(for ((byte (in-bytes (port->bytes c-in)))) > (printf "~x " byte)) > > > The entry above above hangs on port->bytes. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users
____________________ Racket Users list: http://lists.racket-lang.org/users