Francois PIETTE wrote: > To broadcast on 255.25.255.255, use connect() and then send(). > Connect() will set SO_BROADCAST option at the socket level.
Thanks, I have to use the listening socket in order to avoid Bind errors, setting SO_BROADCAST after Listen actually works fine. Happy Holidays -- Arno Garrels > -- > francois.pie...@overbyte.be > The author of the freeware multi-tier middleware MidWare > The author of the freeware Internet Component Suite (ICS) > http://www.overbyte.be > > > ----- Original Message ----- > From: "Arno Garrels" <arno.garr...@gmx.de> > To: <twsocket@elists.org> > Sent: Thursday, December 23, 2010 12:20 PM > Subject: [twsocket] UDP broadcast error "Permission denied" > > >> Hi, >> >> When I try a SendTo() address "255.255.255.255" with an UDP listening >> TWSocket I get error WSAEACCES "Permission denied", is this normal?. >> SendTo() "192.168.1.255" works, Firewall is turned off. >> >> procedure TMyServer.UdpListen; >> begin >> if FUDP = nil then >> FUDP := TWSocket.Create(nil); >> FUDP.Proto := 'udp'; >> FUDP.Addr := '0.0.0.0'; // listening on one interface >> doesn't change it. >> FUDP.Port := '30003'; >> FUDP.OnDataAvailable := UdpDataAvailable; >> FUDP.ReuseAddr := TRUE; >> FUDP.Listen; >> end; >> >> procedure TMyServer.SendHelo; >> var >> Dst : TSockAddrIn; >> DstLen : Integer; >> Buf : AnsiString; >> begin >> FillChar(Dst, SizeOf(Dst), 0); >> Dst.sin_family := AF_INET; >> Dst.sin_port := WSocket_htons(StrToIntDef(FPort, 30003)); >> Dst.sin_addr.S_addr := u_long(INADDR_BROADCAST); >> Buf := 'Helo'; >> if FUDP.SendTo(Dst, DstLen, PAnsiChar(Buf), Length(Buf) + 1) = -1 >> then raise >> Exception.Create(WSocketErrorDesc(WSocket_WSAGetLastError)); end; >> >> -- >> Arno Garrels >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be