From: jsancho Date: Wed, 13 Jul 2011 08:02:52 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=1b020d036cd9adcf8077901dd453e9d61257cbb9;p=gacela.git --- diff --git a/src/gacela.c b/src/gacela.c index 737766a..dc5795a 100644 --- a/src/gacela.c +++ b/src/gacela.c @@ -133,10 +133,10 @@ init_gacela_client () void gacela_client (char *hostname, int port) { - int sockfd; + int sockfd, n; struct hostent *server; struct sockaddr_in serv_addr; - + char buffer[256]; char *line; char *history_path; @@ -160,12 +160,25 @@ gacela_client (char *hostname, int port) if (!line) break; if (line && *line) { - printf ("%s\n", line); add_history (line); + write (sockfd, "(", 1); + n = write (sockfd, line, strlen (line)); + write (sockfd, ")", 1); + if (n < 0) + error("ERROR writing to socket"); + + bzero (buffer, 256); + n = 0; + while (n == 0) + n = read (sockfd, buffer, 255); + if (n < 0) + error("ERROR reading from socket"); + printf ("%s\n", buffer); } free (line); } + close (sockfd); write_history (history_path); free (history_path); } diff --git a/src/gacela_server.scm b/src/gacela_server.scm index ef7b24e..978ea8c 100644 --- a/src/gacela_server.scm +++ b/src/gacela_server.scm @@ -58,11 +58,13 @@ (cond ((char-ready? sock) (catch #t (lambda () - (let ((exp (read sock))) + (let ((exp (car (read sock)))) + (format #t "~a~%" exp) (cond ((eof-object? exp) (close sock)) (else - (format sock "~a~%" (primitive-eval exp)))))) + (format #t "~a~%" (primitive-eval exp)) + (format sock "~a" (primitive-eval exp)))))) (lambda (key . args) (let ((fmt (string-concatenate (list (cadr args) "~%"))) (params (caddr args)))