--- In [email protected], "Indika Bandara" <[EMAIL PROTECTED]> wrote: > > thank you guys, > > i'll try with the ideas u mentioned, > some other questions regarding my situation. > > in my client it has to have a socket opened for days.(reason > is this host-an embedded device- takes quite lot of time to > init the socket so for a real time thing it won't work to > init sockets each time)
In theory a socket can be kept open for weeks if the network doesn't produce any dropouts. > can a TCP/IP socket do this. i.e. keep the socket conected > without hanging up? it has to do the same thing(send files) > within the same socket at different times. can it be done? I would recommend the same approach that many professional companies use: make sure that a keep-alive message packet (this is an IP packet with your own data, in other words one of your self-defined messages such as the login message and the Send Me Some File message and the various acknowledgement messages) is sent over the wire every few seconds or at least within a predefined time frame. This will keep the connection alive as long as you need it (or until some network device happens to drop an IP packet). With TCP/IP sockets you always have to be aware of the possibility that a connection drops; a keep-alive message every (let's say) 30 seconds is an appropriate and widely-used way to check whether the connection is still alive, but if it breaks, you will have to make your code able to re-establish the connection. > by sending a starting sequence each time a new file is sent > will work? Send a request packet every time you need something transferred just in order to check that the connection is still alive and, if it's not, to re-establish it. > anyway, how can i decide a proper starting seq since it > should be not in the sending packet? i'm sending a jpeg file. It doesn't matter what the starting sequence contains; keep in mind that the actual data are never sent in the first packet sent to the communication partner, actual data are always sent in the second packet only. Re-read my paragraphs about the communication protocol, then you will notice that every communication begins with a request packet; only if this is acknowledged the actual data packets are sent. Regards, Nico To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
