Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Udp connection problem
@ 2007-01-05 19:23 Frederico Valente
  2007-01-06 10:23 ` [Caml-list] " Stéphane Glondu
  2007-01-08 14:27 ` Serge Aleynikov
  0 siblings, 2 replies; 6+ messages in thread
From: Frederico Valente @ 2007-01-05 19:23 UTC (permalink / raw)
  To: caml-list

Hi!

	I am trying to communicate with an udp server currently in my computer.
The problem is that although I can send messages, and they are correctly 
received, I dont get any message back (I should). Running a sniffer I 
get an ICMP Unreacheable (Port Unreacheable) after the server response.
	
	Here is the code I'm using:

let serverPort = 4001;;
let serverAddress = Unix.ADDR_INET(Unix.inet_addr_of_string "127.0.0.1", 
serverPort);;

let open_connection sockaddr =
	let domain = Unix.domain_of_sockaddr sockaddr in
	let sock = Unix.socket domain Unix.SOCK_DGRAM 0 in
	try Unix.connect sock sockaddr ;
		(Unix.in_channel_of_descr sock, Unix.out_channel_of_descr sock)
	with exn -> Unix.close sock; raise exn
;;


let mainLoop =
	let inChannel,outChannel = open_connection serverAddress in

	while true do
		output_string outChannel "(message)";
		flush outChannel;
		let r=input_line inChannel in
		Printf.printf "%s" r;
	done
;;

mainLoop;;

	If there's anyone willing to see if the problem lies in this simple 
code I would be extremely grateful.
	I am compiling with ocamlopt in a 3.2Gh Pentium-d in 32 bits and 
running gentoo linux.

	Thanks in advance!


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

end of thread, other threads:[~2007-01-09 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05 19:23 Udp connection problem Frederico Valente
2007-01-06 10:23 ` [Caml-list] " Stéphane Glondu
2007-01-06 16:52   ` Frederico Valente
2007-01-08 14:27 ` Serge Aleynikov
2007-01-08 23:58   ` Frederico Valente
2007-01-09 21:24     ` Serge Aleynikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox