From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 93B60BC6B for ; Wed, 10 Oct 2007 03:31:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKvIC0fRVca6mGdsb2JhbACOSQIBAQcCCBEW X-IronPort-AV: E=Sophos;i="4.21,251,1188770400"; d="scan'208";a="17777137" Received: from rv-out-0910.google.com ([209.85.198.186]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Oct 2007 03:31:37 +0200 Received: by rv-out-0910.google.com with SMTP id k20so44668rvb for ; Tue, 09 Oct 2007 18:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; bh=VNhIJI9k1kuwtkGyPvv3qC2nItNL0kE0YaafWPH2Fyg=; b=eoGmlbHXFRRgRvEZLkzwH6VmCDD5ugh3ugOuexMEEpHHwuElOkq3jx5nr0+9Mo5BDcbnKMmCBPNe0odfB2jprgGH7XBa3R2g24Zp6PwreUJuPzLobRSzrjYroAHgDRDaYDLUAHFF0CIn7uI5Z0on14MVsnatIL8pOwNwcVBL4q8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=MnRTSK8l91tfMFArIB101jey7VzH9mF45EilcprSsUEwYnI4AMPxSvwsd4SA7XlZsN0Z7Bq/IKs+ARg2Ts0wXPNLRcDkIAB/9L9ZV6E+UU3pSLTUl+/fHPU1xe8nNWQUR+qE1xeSSPOcJNfAr5UbqCc7AVxRM7g4m8ntpJEnSsw= Received: by 10.140.178.17 with SMTP id a17mr56849rvf.1191979895773; Tue, 09 Oct 2007 18:31:35 -0700 (PDT) Received: from ?192.168.1.100? ( [75.49.37.224]) by mx.google.com with ESMTPS id l17sm254611rvb.2007.10.09.18.31.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Oct 2007 18:31:34 -0700 (PDT) Message-ID: <470C2B72.3090704@gmail.com> Date: Tue, 09 Oct 2007 18:31:30 -0700 From: Reed Wilson Reply-To: cedilla+ocaml@gmail.com User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: UDP broadcast from Windows Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; setsockopt:01 printf:01 printf:01 ocaml:01 unix:01 unix:01 defined:02 string:02 string:02 seems:03 let:03 let:03 middle:94 broadcast:92 broadcast:92 Hi guys! I'm in the middle of writing a program which does a UDP broadcast, but I noticed it doesn't work on Windows. Here's the source: try ( let sock = Unix.socket Unix.PF_INET Unix.SOCK_DGRAM 0 in Unix.setsockopt sock Unix.SO_BROADCAST true; let sent = Unix.sendto sock "ping" 0 4 [] (Unix.ADDR_INET ((Unix.inet_addr_of_string "255.255.255.255"), 12345)) in Printf.printf "Sent %d\n" sent; ) with | Unix.Unix_error (x,y,z) -> Printf.printf "%S - %s,%s\n" (Unix.error_message x) y z ;; I noticed that when I force the address by replacing: Unix.inet_addr_of_string "255.255.255.255" with: Obj.magic "\255\255\255\255" it _seems_ to work fine. I looked around in the OCaml source, and it looks like the broadcast address is specifically disallowed unless HAS_INET_ATON is defined? Why is this? And am I breaking anything by using magic? Thanks Reed