Groups | Blog | Home
all groups > dotnet general > september 2005 >

dotnet general : UPD in VB.NET


ninadsd NO[at]SPAM gmail.com
9/30/2005 11:27:00 PM
I have the following VB6 code

-------------------------------------
Option Explicit
Const ByteCode =3D "=FF=FF=FF=FF"

Private Sub Form_Load()
wsk.Protocol =3D sckUDPProtocol
wsk.RemoteHost =3D "255.255.255.255"
wsk.RemotePort =3D 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 =3D "=FF=FF=FF=FF"
udpClient.Connect("255.255.255.255", 27015)
Dim sendBytes As [Byte]() =3D Encoding.ASCII.GetBytes(ByteCode &
"infostring")
udpClient.Send(sendBytes, sendBytes.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() =3D
udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String =3D
Encoding.ASCII.GetString(receiveBytes)
----------------------------------------

But the 2nd last line blocks the program. Please help.
learner
10/1/2005 6:29:58 PM
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


[quoted text, click to view]
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)
----------------------------------------

But the 2nd last line blocks the program. Please help.

AddThis Social Bookmark Button