Hi all!
Can anyone help me pinpointing what is wrong with the follow tcp server code?
(define (tcp-server-test) (let ((p (read (open-tcp-server (list port-number: 20000 reuse-address: #t))))) (pp (read p)) (write 'yea! p) (force-output p) (close-port p)))
(tcp-server-test)
If run this code inside a console and, from another console I run the following client code:
(define (tcp-test) (let ((connection (open-tcp-client (list server-address: "192.168.60.239" port-number: 20000))))
(write 'allo!! connection) (force-output connection) (read connection) (close-port connection)))
(tcp-test)
I always get a "broken pipe" error. Note that the ip address is correct. I tried to replace the server with the good old netcat and it works just fine (i.e. that the client successfully connects to the nc server). Is anything wrong with the server code?
Thanks!
-- David
Afficher les réponses par date
Try this code:
(define (tcp-server-test) (let ((p (read (open-tcp-server (list server-address: "*:2000" reuse-address: #t))))) (pp (read p)) (write 'yea! p) (force-output p) (close-port p)))
Vasil.
David St-Hilaire пишет:
Hi all!
Can anyone help me pinpointing what is wrong with the follow tcp server code?
(define (tcp-server-test) (let ((p (read (open-tcp-server (list port-number: 20000 reuse-address: #t))))) (pp (read p)) (write 'yea! p) (force-output p) (close-port p)))
(tcp-server-test)
If run this code inside a console and, from another console I run the following client code:
(define (tcp-test) (let ((connection (open-tcp-client (list server-address: "192.168.60.239" port-number: 20000))))
(write 'allo!! connection) (force-output connection) (read connection) (close-port connection)))
(tcp-test)
I always get a "broken pipe" error. Note that the ip address is correct. I tried to replace the server with the good old netcat and it works just fine (i.e. that the client successfully connects to the nc server). Is anything wrong with the server code?
Thanks!
-- David _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
vasil wrote:
Try this code:
(define (tcp-server-test) (let ((p (read (open-tcp-server (list server-address: "*:2000" reuse-address: #t))))) (pp (read p)) (write 'yea! p) (force-output p) (close-port p)))
Thanks alot Vasil! Its working perfectly. Althought, I'm not sure what was wrong with the code I submitted. O_o
-- David
Left [adrien]/tmp % gsi-gambit tcp.scm Right [adrien]/tmp % telnet 127.0.0.1 20000 Right Trying 127.0.0.1... Right Connected to localhost. Right Escape character is '^]'. Right hi Right yea!Connection closed by foreign host. Left hi
I guess it works. 4.5.1 on FreeBSD (not released yet, I have some last tweaks before upgrading it in the FreeBSD ports)
However, the client is buggy. It does not send and EOL character, so the server wants to read more on the socket. And then the clients wants to read it too. Though you flushed, I think that the TCP server, with read, it too high level to know that it has finished reading the symbol.
P!
2009/8/25 David St-Hilaire sthilaid@iro.umontreal.ca:
Hi all!
Can anyone help me pinpointing what is wrong with the follow tcp server code?
(define (tcp-server-test) (let ((p (read (open-tcp-server (list port-number: 20000 reuse-address: #t))))) (pp (read p)) (write 'yea! p) (force-output p) (close-port p)))
(tcp-server-test)
If run this code inside a console and, from another console I run the following client code:
(define (tcp-test) (let ((connection (open-tcp-client (list server-address: "192.168.60.239" port-number: 20000))))
(write 'allo!! connection) (force-output connection) (read connection) (close-port connection)))
(tcp-test)
I always get a "broken pipe" error. Note that the ip address is correct. I tried to replace the server with the good old netcat and it works just fine (i.e. that the client successfully connects to the nc server). Is anything wrong with the server code?
Thanks!
-- David _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list