Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 11th, 2007, 03:08 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in retrieving datas through socket

Hello,

We are currently using a program where we recieve the details from the client. 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=117.96.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
Hemalatha


 
Old August 14th, 2007, 09:30 AM
Registered User
 
Join Date: Aug 2007
Location: , , Norway.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perhaps if you post the source around line 346 and 288 of E:\stepII\Server.cs it will be easier to say what might be going wrong...
 
Old August 21st, 2007, 10:33 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply BrainWave
I am putting on the code(a part of as it is very huge)

Code:
if (text7 == "DeviceName")
                            {
                               [u] text2 = textArray2[1];</u>                                text2 = this.GetUnitNoString(text2);
                                string text5 = DateTime.Now.ToString() + ":  Client " + text2 + "  Connected :  " + text3;

                                //text5 
                                this.lbMsgLog.Items.Add(text3);


The Underlined part is place where the error is thrown.

thanks and regards
cmrhema

 
Old August 22nd, 2007, 03:07 AM
Registered User
 
Join Date: Aug 2007
Location: , , Norway.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you sure the error occurs where you've underlined? It seems more likely that it happens at:

Code:
this.lbMsgLog.Items.Add(text3);
In that case, I'm no expert - I haven't used ListBox much. Could it be that text3 is null? I don't know how ListBox would react to that...

You haven't posted anything about the second exception, but that might be a follow on exception.
 
Old August 22nd, 2007, 04:51 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. Infact I was referring to the second exception.
The first exception has been solved. It was indeed a null value being sent.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error establishing socket for SQL Connection. mcw22 Java Databases 0 March 19th, 2007 09:29 PM
sending email using .net 1.1 socket error amol.mahajan85@gmail.com ASP.NET 1.0 and 1.1 Basics 1 December 17th, 2006 06:25 PM
Problem with mod_jk, socket is not connected error kouterguine BOOK: Professional Apache Tomcat 0 October 6th, 2005 08:28 AM
windows socket error happytony .NET Framework 2.0 0 November 27th, 2004 01:44 AM
Php socket error madman Pro PHP 0 November 10th, 2004 10:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.