By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

sending UDP packet to broadcast address

P: n/a
Hi, im trying to broadcast a UDP packet to my networks broadcast address
(192.168.255.255) which i have verified with my network admin is the correct
address. i can ping that address and get responses from the other computers
on the network (via the command prompt) but when i attempt to send a UDP
packet, it does not go through. there are no errors, however, i am listening
on another computer on the same port, but the packet is not received. heres
the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim socSend As New Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)

Dim bt() As Byte =
System.Text.ASCIIEncoding.ASCII.GetBytes(Dns.Resol ve(Dns.GetHostName).AddressList(0).ToString & "-" & "user.name")

socSend.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1)
socSend.SendTo(bt, 0, bt.Length, SocketFlags.None, New
IPEndPoint(Dns.Resolve("192.168.255.255").AddressL ist(0), SEND_PORT))

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

socServer = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)

ReDim btServer(4095)

socServer.Bind(New
IPEndPoint(Dns.Resolve(Dns.GetHostName).AddressLis t(0), PORT))

Call Poll()

End Sub

Private Sub Poll()

While True

If socServer.Available 0 Then socServer.Receive(btServer, 0,
SocketFlags.None)

' Me.Invalidate(True)
Application.DoEvents()

ParseText(btServer)

End While

End Sub

both SEND_PORT and PORT are constants (11500 and 11000). any help would be
great. thanks

--
-iwdu15
Apr 19 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.