Unable to send UDP Packet

Discussion in 'Site Programming, Development and Design' started by Zilog80, Jan 12, 2011.

  1. I get this simple code on button click event:

    Code:
    Dim udpClient As New UdpClient
    Dim buf(101) As Char
    Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(buf)
    
    For x As Integer = 0 To 5
       sendBytes(x) = CInt("&HFF")
    Next
    
    Dim MacAddress As String
    MacAddress = "00AB221F4E5A"
    
    Dim i As Integer = 6
    For x As Integer = 1 To 16
       sendBytes(i) = CInt("&H" + MacAddress.Substring(0, 2))
       sendBytes(i + 1) = CInt("&H" + MacAddress.Substring(2, 2))
       sendBytes(i + 2) = CInt("&H" + MacAddress.Substring(4, 2))
       sendBytes(i + 3) = CInt("&H" + MacAddress.Substring(6, 2))
       sendBytes(i + 4) = CInt("&H" + MacAddress.Substring(8, 2))
       sendBytes(i + 5) = CInt("&H" + MacAddress.Substring(10, 2))
       i += 6
    Next
    
    Dim myAddress As String = "www.someDomainHere.com"
    
    Try
       udpClient.Send(sendBytes, sendBytes.Length, myAddress, 9)
       Label1.Text = "Succes!"
    Catch ex As Exception
       Label1.Text = " Error:" & ex.Message
    End Try
    
    i always get this error:

    Error:Request for the permission of type 'System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    I need to change something on control panel for change properly permissions or its impossible to send UDP Packet from Winhost hosted page?

    Thx in advance.
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  3. Works like a charm now.
    Your replys are as fast as the speed and light. Is nicely :)
     

Share This Page