.NET Framework - MultiCast

Asked By sLorent
26-Jan-09 07:33 AM
Hello!

I'd like to send a MultiCast packet, but I don't really know how to do this
with powershell.

I tried:


$multiep = New-Item
System.Net.IPEndPoint([System.Net.IPAddress]::Parse("234.5.6.7"),58432)
$sock = New-Item
System.Net.Sockets.Socket([System.Net.Sockets.AddressFamily]'InterNetwork',
[System.Net.Sockets.SocketType]'Dgram',
[System.Net.Sockets.ProtocolType]'Udp' )
$d = New-Item
System.Net.Sockets.MulticastOption([System.Net.IPAddress]::Parse("234.5.6.7"))
$iep = New-Item System.Net.IPEndPoint(System.Net.IPAddress.Any,58432)
$sock.Bind($iep);
$sock.SetSocketOption([System.Net.Sockets.SocketOptionLevel]'IP',
[System.Net.Sockets.SocketOptionName]'AddMembership', $d)
$sock.SendTo("test",[System.Net.Sockets.SocketFlags]'None', $multiep)


IS this correct?
System.Net.Sockets.SocketOptionLevel
(1)
System.Net.Sockets.SocketOptionName
(1)
System.Net.Sockets.ProtocolType
(1)
System.Net.Sockets.SocketFlags
(1)
System.Net.Sockets.SocketType
(1)
System.Net.IPEndPoint
(1)
System.Net.Sockets.Socket
(1)
System.Net.IPAddress
(1)
  Marco Shaw [MVP] replied...
30-Jan-09 03:03 PM
Still stuck/looking for a solution?

Marco


--
*Microsoft MVP - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition (due December
15th, 2008)
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
  sLorent replied...
12-Feb-09 07:53 AM
... yes ...
  sLorent replied...
12-Feb-09 07:56 AM
yes!
  Marco Shaw [MVP] replied...
12-Feb-09 03:04 PM
I've been playing with this a bit.  I need to confirm/figure out if a
network tracing program can see this packet or not so I know it is
actually working.

One thing: "New-Item" isn't the cmdlet you're looking for to create an
instance of a class, that would be "New-Object".

Marco

--
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Create New Account