?
Solved

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

Posted on 2001-08-14
4
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
DennisBorg earned 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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.

719 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