error while retrieving values from socket

C

cmrhema

Hello,

We are currently using a program where we recieve the details from the
client. Developed in C#.It is recieved through sockets.
It is working fine. i.e. When we start the program afresh we do get
details properly. We recieve the data as strings and we store in a list
box.But after two or three days we have an error stating as below


System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.ListBox.ItemArray.IndexOf(Obj ect item, Int32
stateMask)
at System.Windows.Forms.ListBox.ObjectCollection.AddI nternal(Object
item)
at System.Windows.Forms.ListBox.ObjectCollection.Add( Object item)
at StepIIServer.Server.RunClient2() in E:\stepII\Server.cs:line 346
8/7/2007 8:19:26 PM Error :$<MSG.Info.ServerLogin>
$DeviceName=352022000365427
$Software=steppII_2.4.3_final
$Hardware=STEPPII-55
$LastValidPosition=$GPRMC,145245.573,A,2941.6635,N
,07659.7630,E,0.00,2.34,070807,,
$IMEI=352022000365427
$PhoneNumber=
$LocalIP=555.36.20.147
$CmdVersion=2
$SUCCESS
$<end>
&IMEI=352022000365427,Distance=63936,
&GPRMC,145240.574,A,2941.6635,N,07659.7630,E,0.00,2 .34,070807,,
<end>

and another error stating
ping
System.Net.Sockets.SocketException: An existing connection was forcibly
closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer)
at StepIIServer.Server.RunClient2() in E:\stepII\Server.cs:line 288
8/7/2007 5:51:34 AM Error :&IMEI=352022000370849,Distance=1487,
&GPRMC,001830.515,A,2943.0151,N,07658.9818,E,0.00,8 .79,070807,,
<end>

Will you please help

thanks
Hema
 
P

Peter Duniho

cmrhema said:
Hello,

We are currently using a program where we recieve the details from the
client. Developed in C#.It is recieved through sockets.
It is working fine. i.e. When we start the program afresh we do get
details properly. We recieve the data as strings and we store in a list
box.But after two or three days we have an error stating as below

You didn't post any code, so the best anyone can do is guess. My guess
is this: you have a valid socket error (connection was reset, generating
the one socket exception), which somehow results in you attempting to
add a null string reference to your list box (generating the
NullReferenceException).

Fix your socket error handling so that it catches the reset connection
exception and doesn't try to add a null reference to the ListBox, and I
would guess the NullReferenceException will go away. You'll still get
the SocketException, but since you'll be handling it, that's okay.

Pete
 

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