Solved

UDP Boradcast source IP address (1 liner easy if you know it!)

Posted on 2001-08-14
4
184 Views
Last Modified: 2013-11-13
I am currently working on my app's socket security...
In a couple of servers I listen for UDP broadcasts to do a few different thingies... but I need to verify the source of the broadcast before acting on it.

WinBroadcast is the winsock control I am using...
I put a line where the comment in the code below is that read...

msgbox WinBroadcast.RemoteHost & vbcrlf & _
 WinBroadcast.RemoteHostIP, vbInformation

but these properties all came back as "" (null)
How can I tell the IP address of the broadcaster??

Thanks guys n gals....



Private Sub WinBroadcast_DataArrival(ByVal bytesTotal As Long)
 Dim thestr As String
 '
 ' Need code here to determine the source IP
 '
 WinBroadcast.GetData thestr
 Select Case thestr
    Case "Terminate"
         Unload Me
         End
    Case "Show"
         Me.Show
 End Select
End Sub
0
Comment
Question by:LuckyPhill
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
DennisBorg earned 50 total points
ID: 6385917
You have to use GetData first, then check the RemoteHost and RemoteHostIP properties.

When you receive something, you'd perform the following steps:

   1) Get the data sent
   2) Inspect the RemoteHost/RemoteHostIP
   3) If you like the sender, act on the request, otherwise ignore the request.


-Dennis Borg
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6386024
Clear enought, i think.
0
 
LVL 1

Author Comment

by:LuckyPhill
ID: 6386774
damb! do you know I had this line the WRONG side of the getdata and took it out!!

If WinBroadcast.RemoteHostIP <> "127.0.0.1" Then Exit Sub

0
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6388329
You were close. I ran into that once and noticed that the RemoteHost/IP properties were filled in *after* I got the data. It really had me running in circles for a while.

Glad to have helped, and that it was a simple solution for you.

Take care,

Dennis Borg
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now