Socket Issue

Started by
1 comment, last by programmer_tom 12 years, 11 months ago
Hey All

I'm pretty new to socket programming in c++, but i've managed to get a client/server thing going pretty well after a few days.

Everything is all hooked up and I'm sending packets both ways fine in general.

As a test, I tried sending 100 messages at once using send() and recv(), and it looks like I'm getting about half of them
to the other side.

What's the story with ACKing or whatever I need to do to be able to spam messages and guarantee their arrival?

-tom
Advertisement

What's the story with ACKing or whatever I need to do to be able to spam messages and guarantee their arrival?


That depends on what your requirements are. They may be:

It's OK to lose some packets or receive some packets out of order, as long as most of them make it across as fast as possible. This is UDP.
It's OK to wait a little bit now and then, as long as all of the packets make it across in order. This is TCP.

Very seldom will you need any other guarantee. If you do, it's typically of the kind "I guarantee that most packets make it, but if some packet make it out of order, I drop it," which you can implement on top of UDP using a sequence counter.
enum Bool { True, False, FileNotFound };
hey thanks for the reply

ya TCP is fine here.

after looking at it more, looks like when I'm calling recv(), i'm blindly assuming there's one message there.

when i crank msgs fast from the server, that's not the case.

gonna look at building a smarter read().

-tom

This topic is closed to new replies.

Advertisement