Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

867 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

13 Experts available now in Live!

Get 1:1 Help Now