On 12/19/05, Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de> wrote:
> > Anyway, how would I solve the task in scsh with its elaborated socket
> > functions?
>
> Well, just use the first procedure described in the scsh network API:
>
I guess, Martin means something like this:
> (define (ask-server request host-name port-number)
> (let ((socket (socket-connect protocol-family/internet
> socket-type/stream
> host-name
> port-number)))
> (display request (socket:outport socket))
(let ((answer (read-line (socket:inport socket))))
> (close-socket socket) ;;; (*)
> answer)))
(*) Closing the socket like this is not portable across OS (eg. on my
Linux machine this raises an error), but closing the inport is
portable:
(close-input-port (socket:inport socket)
[ see http://www.scsh.net/docu/html/man-Z-H-5.html#node_idx_1002 ]
Immanuel wrote:
> If you have some socket server running on port 8080 which understands
> the request "something" and returns anything, but with a delay of say 1
> sec. then scsh simply hangs without any error message. Unfortunately I
> can't provide the server code since it is some third party service (Note
> it doesn't cause problems when "ask-server" is running under s48 so the
> external service is not the point).
I tested this on my machine with netcat (nc) listening on some port
and it works fine. I cannot observe the "hanging" behavior Immanuel
described. Maybe you, Immanuel, can give more details on what you mean
with "hanging"? (You don't mean that scsh is waiting for the input for
1sec., do you?)
Yours,
Andreas.
|