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.
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
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:
[size=2][color=#0000ff][/left]
Imports[/color][/size][size=2] System.IO
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System.Net.Sockets.Socket
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System.Net
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] Microsoft.VisualBasic
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System.Runtime.InteropServices
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System.Net.Sockets
[/size][size=2][color=#0000ff]Imports[/color][/size][size=2] System.Text
[/size][size=2][color=#0000ff]Public[/color][/size][size=2] [/size][size=2][color=#0000ff]Class[/color][/size][size=2] UDPSrv
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] receivingUdpClient [/size][size=2][color=#0000ff]As[/color][/size][size=2] UdpClient
[/size][size=2][color=#0000ff]Public[/color][/size][size=2] RemoteIpEndPoint [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] System.Net.IPEndPoint("127.0.0.1", 8000)
[/size][size=2][color=#0000ff]Shared[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] Main()
[/size][size=2][color=#0000ff]Try
[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] receivingUdpClient [/size][size=2][color=#0000ff]As[/color][/size][size=2] UdpClient
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] RemoteIpEndPoint
[/size][size=2][color=#0000ff] ** Dim[/color][/size][size=2] receiveBytes [/size][size=2][color=#0000ff]As[/color][/size][size=2] [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] clientdata
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] BitDet [/size][size=2][color=#0000ff]As[/color][/size][size=2] BitArray
BitDet = [/size][size=2][color=#0000ff]New[/color][/size][size=2] BitArray(receiveBytes)[/size][size=2][color=#008000]
[/color][/size][size=2][/size][size=2][color=#0000ff]Const[/color][/size][size=2] portNumber [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size][size=2] = 8000
[/size][size=2][color=#008000]
[/color][/size][size=2]Console.WriteLine("Waiting for connection...")
receivingUdpClient = [/size][size=2][color=#0000ff]New[/color][/size][size=2] System.Net.Sockets.UdpClient(portNumber)
Console.WriteLine("Connection accepted.")
Console.WriteLine(("Client sent: " + clientdata))
[/size][size=2][color=#008000]'Dim responseString As String = "Connected to server."
[/color][/size][size=2]clientdata = clientdata + 1
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] sendBytes [/size][size=2][color=#0000ff]As[/color][/size][size=2] [Byte]() = Encoding.ASCII.GetBytes(clientdata)
Console.WriteLine(("Message Sent /> : " + clientdata))
Console.WriteLine("exit")
Console.ReadLine()
[/size][size=2][color=#0000ff]Catch[/color][/size][size=2] ex [/size][size=2][color=#0000ff]As[/color][/size][size=2] Exception
Console.WriteLine(ex.ToString())
Console.ReadLine()
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Try
[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub
End[/color][/size][size=2] [/size][size=2][color=#0000ff]Class
[left][/color][/size]
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