Socket questions: Error detection/correction, packet order?

Fazzyer

Member
Joined
Jul 29, 2005
Messages
16
Programming Experience
5-10
Hi,

I've got 2 questions about socket programming.

Background: I wrote a server/client chat-program for me and my friends using asynchronous TCP-sockets. Now I want to add a "file send"-option, that sends a file from one user to another (peer-o-peer), that should use a different socket on an different port than the chat. I intend to make the file transfer synchronous, so that no problems with multithreading can occur.

Now my questions:

A) Do TCP-sockets implement some type of error correction or error detection for the sent bytes or do I have to care about that by myself? File transfer is useless, if the file transfered is corrupted after receiving...
What error detection or correction mechanisms are fast enough to check each received packet, if I have to care about that?

B) What happens if a packet is lost or by some reason delayed and arriving after some of the following packets have already been received? Do I have to count the packets and care about their arrival order or do the sockets care about that for me?

In anyone could help me and answer these questions I would be very thankful.

- Fazzyer
 
This is part of the low-level TCP protocol implementation, and you don't have to care about it, you either get a full transmission or a broken connection.

You either have to run the transmission in a thread different than UI thread, or use an application type without UI (like console application). Multithreading shouldn't be a problem.
 
Back
Top