UDP server problem

Jeffo

Member
Joined
Apr 26, 2005
Messages
9
Programming Experience
1-3
Hi, Im trying to develop a udp client server application.​

Ive used code ive seen from other examples on the net, im just having a few problems with the server application at the moment.

VB.NET:
PublicClass UDPSrv
Dim receivingUdpClient As UdpClient
Public RemoteIpEndPoint AsNew System.Net.IPEndPoint("127.0.0.1", 8000)
SharedSub Main()
Try
Dim receivingUdpClient As UdpClient
Dim RemoteIpEndPoint
** Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
Dim clientdata
Dim BitDet As BitArray
BitDet = New BitArray(receiveBytes)Const portNumber AsInteger = 8000
Console.WriteLine("Waiting for connection...")
receivingUdpClient = New System.Net.Sockets.UdpClient(portNumber)
Console.WriteLine("Connection accepted.")
Console.WriteLine(("Client sent: " + clientdata))
'Dim responseString As String = "Connected to server."
clientdata = clientdata + 1
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(clientdata)
Console.WriteLine(("Message Sent /> : " + clientdata))
Console.WriteLine("exit")
Console.ReadLine()
Catch ex As Exception
Console.WriteLine(ex.ToString())
Console.ReadLine()
EndTry
EndSub
EndClass

The line Im having a problem is marked with **
I get a null reference exception, jsut wondering if anyone can clear this up for me, as im new to using vb.net and creating udp applicaitons so any help would just be great.
Thanks
 
You have declared receivingUdpClient as a UdpClient but you haven't instantiated it. When you get an unhandled exception and click the break button, you can mouse over all your variables to see what values they hold, or type their names into the Watch window.
 
Back
Top