Solved

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

Posted on 2001-08-14
4
187 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

838 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