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;
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);
}
(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)))