caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] reading from socket connection
@ 2003-04-28 19:09 Christian.Schaller
  2003-05-05 15:19 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Christian.Schaller @ 2003-04-28 19:09 UTC (permalink / raw)
  To: caml-list

Hi,

When connecting, let's say to a nntp server and just exchanging some
information, the OCaml manual tells me to use open_connection from the Unix
library.  This works well, however, how can I read the output from the
remote server?  My first try was a readLines function (see below) to read
until EOF, however there's no EOF, thus my program hanging.  Any hints?  Is
this a cygwin related problem?

Thanks,
  Chris

open Unix

let server = inet_addr_of_string "10.10.10.10"
let sockaddr = ADDR_INET (server, 119)

let readLines ch =
  try
    while true do
      print_endline (input_line ch)
    done
  with End_of_file -> ();;

let client_fun ic oc =
  output_string oc "help\n";
  flush oc;
  readLines ic

let _ = 
  let ic, oc = open_connection sockaddr in
  client_fun ic oc;
  shutdown_connection ic

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-05 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-28 19:09 [Caml-list] reading from socket connection Christian.Schaller
2003-05-05 15:19 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).