CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

TCP Socket question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spesh



Joined: 28 Mar 2006
Posts: 10

View user's profile Send private message

TCP Socket question
PostPosted: Wed May 21, 2008 4:05 am     Reply with quote

I'm developing an application for transfering data over sockets. The client application (Windows C#) connects to a socket and then transfers a reading following a request.

It seems to work fine most of the time, but every now and again I see a message re-transmission (using Wireshark Network sniffer) and then I lose connection and can't re-connect. My PIC code is based on Ex14 supplied with the CCS TCP stack.

My question is this : Is it OK to leave the socket connected whilst the readings are made (this could be a long time, e.g. 1 hour) or is it best to connect, read/write and disconnect each time I want a reading (probably every 10 seconds or so) ?

Regards

Alan
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed May 21, 2008 6:48 am     Reply with quote

hi
in timeout also consider the time after which your connection is terminated by other side. Make this your limiting factor of socket time out as you are not going to distributed system so no question of network overloading is here
_________________
sohail khan
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Wed May 21, 2008 9:24 am     Reply with quote

I had a problem with long term TCP connections at one time. They would stall and I'd need to disconnect and reconnect. What I found in the "tcp.c" file was a few lines with a comment "TODO: review this". Below that were two lines:
Code:
//TODO: review this
//DSR ADD 063004
//i do this because if i am a server, i don't want to timeout.
if ( (ps->smState == TCP_ESTABLISHED) && (ps->Flags.bServer == TRUE) )
  continue;
Commenting out those lines fixed the problem. The comms still stalled, but after a second or two it would recover.

Since then, I've been able to maintain a continuous TCP connection (continuous data) for days.

Edit: Added the extra comments for the code fragment to make locating it in the source much easier.
_________________
Andrew


Last edited by andrewg on Fri May 23, 2008 10:18 am; edited 1 time in total
spesh



Joined: 28 Mar 2006
Posts: 10

View user's profile Send private message

PostPosted: Thu May 22, 2008 7:47 am     Reply with quote

Andrew

I can't find that line of code in my TCP stack source.

Which version of the stack are you using ?

Regards

Alan
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Thu May 22, 2008 9:29 pm     Reply with quote

The CCS port of the Microchip v3.75 stack.
_________________
Andrew
Dimmu



Joined: 01 Jul 2007
Posts: 37

View user's profile Send private message

PostPosted: Sun May 25, 2008 8:58 am     Reply with quote

I don't know if this can help but some of the CCS examples are bugged.

Try to print the state of all the defined sockets in your code. Maybe it is just a question of initialisation of variable.

Dimmu
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group