Results 1 to 7 of 7

Thread: UDP .

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    . worm4's Avatar
    Join Date: Jul:2005
    Location: Varna
    Posts: 20,295

    UDP .

    VB.NET,
    Code:
        
        Sub Main()
    
            ComChanel = New ComunicationChannel
            ReadConfig()
            tmrReciveTimer.Interval = 5000
            tmrReciveTimer.Start()
            Try
                SocketNO = 502
                receivingUdpClient = New System.Net.Sockets.UdpClient(SocketNO)
                ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
                ThreadReceive.Start()
            Catch x As Exception
                Console.WriteLine(x.Message)
            End Try
            Do
    
    
            Loop
    
        End Sub
    Public Sub ReceiveMessages()
            Try
                Dim receiveBytes As Byte() = receivingUdpClient.Receive(RemoteIpEndPoint)
                Dim BitDet As BitArray
                BitDet = New BitArray(receiveBytes)
    
                Dim strReturnData As String = System.Text.Encoding.Unicode.GetString(receiveBytes)
                Console.WriteLine("A message is received and being processed. Remote Addres is:")
                Console.WriteLine(RemoteIpEndPoint.Address.ToString)
                Console.WriteLine("The length of the message is " & receiveBytes.Length)
                Dim tempStr1 As String = ""
                Dim tempStr3 As String = ""
                'Dim tempStr2 As String
                For Each reciveByte As Byte In receiveBytes
                    tempStr1 = tempStr1 & Chr(CInt(reciveByte))
                    If Len(Hex(reciveByte)) = 1 Then
                        tempStr3 = tempStr3 & "0" & Microsoft.VisualBasic.Hex(reciveByte) & " "
                    Else
                        tempStr3 = tempStr3 & Microsoft.VisualBasic.Hex(reciveByte) & " "
                    End If
                Next
                Console.WriteLine(tempStr1)
                Console.WriteLine(tempStr3)
                Console.WriteLine(strReturnData)
                SendMesages(receiveBytes, RemoteIpEndPoint.Address, 502)
                NewInitialize()
            Catch e As Exception
                Console.WriteLine(e.Message)
            End Try
        End Sub
        Public Sub NewInitialize()
            Console.WriteLine("Thread *Thread Receive* reinitialized")
            ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
            ThreadReceive.Start()
        End Sub
    
        Public Sub SendMesages(ByVal bytCommand As Byte(), ByVal GLOIP As Net.IPAddress, ByVal intGLOINTPORT As Int16)
    
            Dim pRet As Integer
            Dim udpClient As New Sockets.UdpClient
    
    
            Try
                udpClient.Connect(GLOIP, intGLOINTPORT)
                pRet = udpClient.Send(bytCommand, bytCommand.Length)
                Console.WriteLine("No of bytes send " & pRet)
                Console.WriteLine(Encoding.ASCII.GetString(bytCommand))
                Console.WriteLine("The messege send is")
                Console.WriteLine(Encoding.ASCII.GetChars(bytCommand))
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
        End Sub
    /Hidden:

    :
    . / UDP . . RemoteIpEndPoint.Address . 1 . , ? . . .

    , emebeded, rasbery pi, 1 . .
    "Arbeit macht frei" -
    - . , :..,,--?!
    OgiDogi: , , ..,

  2. #2
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    UDP , . . TCP .

    :
    Code:
    SendMesages(receiveBytes, RemoteIpEndPoint.Address, RemoteIpEndPoint.Port)
    VB Socket.RemoteEndPoint Property

  3. #3
    . worm4's Avatar
    Join Date: Jul:2005
    Location: Varna
    Posts: 20,295
    , , . ?

    VB , , , C# . .
    "Arbeit macht frei" -
    - . , :..,,--?!
    OgiDogi: , , ..,

  4. #4
    Wall-e delian's Avatar
    Join Date: May:2003
    Location: ::1
    Posts: 4,723

  5. #5
    . worm4's Avatar
    Join Date: Jul:2005
    Location: Varna
    Posts: 20,295
    .
    0 . , . - C#. ? . ?
    "Arbeit macht frei" -
    - . , :..,,--?!
    OgiDogi: , , ..,

  6. #6
    Wall-e delian's Avatar
    Join Date: May:2003
    Location: ::1
    Posts: 4,723
    .
    VB, .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |