UPD in VB.NET

N

ninadsd

I have the following VB6 code

-------------------------------------
Option Explicit
Const ByteCode = "ÿÿÿÿ"

Private Sub Form_Load()
wsk.Protocol = sckUDPProtocol
wsk.RemoteHost = "255.255.255.255"
wsk.RemotePort = 27015
wsk.SendData ByteCode & "infostring"
End Sub

Private Sub wsk_DataArrival(ByVal bytesTotal As Long)
Dim strReceived As String
wsk.GetData strReceived
MsgBox (strReceived)
End Sub
---------------------------------------

I get the required result. I was trying the same in VB.NET but
unsuccessful.

---------------------------------------
Dim udpClient As New UdpClient
Const ByteCode = "ÿÿÿÿ"
udpClient.Connect("255.255.255.255", 27015)
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(ByteCode &
"infostring")
udpClient.Send(sendBytes, sendBytes.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() =
udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String =
Encoding.ASCII.GetString(receiveBytes)
 
L

learner

don't you have to studio vb to work with? try download the 2005 express vb
from msdn
once you have installed that, all you have to do is open a new project as
console app and fill the blank

Hint, I suspect you need sub main. in addition to your sub form_load,
DataArrival


I have the following VB6 code

-------------------------------------
Option Explicit
Const ByteCode = "ÿÿÿÿ"

Private Sub Form_Load()
wsk.Protocol = sckUDPProtocol
wsk.RemoteHost = "255.255.255.255"
wsk.RemotePort = 27015
wsk.SendData ByteCode & "infostring"
End Sub

Private Sub wsk_DataArrival(ByVal bytesTotal As Long)
Dim strReceived As String
wsk.GetData strReceived
MsgBox (strReceived)
End Sub
---------------------------------------

I get the required result. I was trying the same in VB.NET but
unsuccessful.

---------------------------------------
Dim udpClient As New UdpClient
Const ByteCode = "ÿÿÿÿ"
udpClient.Connect("255.255.255.255", 27015)
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(ByteCode &
"infostring")
udpClient.Send(sendBytes, sendBytes.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() =
udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String =
Encoding.ASCII.GetString(receiveBytes)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top