开发者

Image sequence transfer using socket, noob question

I am building an C++ application server-client where the client sends an image (170kb) to a server every 200ms.

Using UDP, the files uncompressed are over 64kbs allowed by each datagram (I'd like to avoid compressing the files if possible).

On the other hand I'm having problems setting a TCP connection, I managed stablish a connection but only the first 开发者_运维百科file is sent, do I need to connect, send the file, break connection and do the same process for all files?

Both sockets were set up using boost asio. Should I another protocol?

thanks in advance


First of all, don't use UDP for that. TCP was designed for what you need and does a lot already by itself. From you POV, TCP connections will always somehow work, whereas with UDP, you'll have to take care of packet sequencing, packets missings, etc. For example, an image takes 3 packets to transfer, UDP does not guarantee that all 3 packes will arive at the destination, and if they do, it does not guarantee that they'll arrive in the same order you've sent.

Now, for TCP, reestablishing a new connection for every file could be done, yes, but it is not necessary. Ideally your code should check to see if the connection is established, if not, reconnect. Now, why is only the 1st file transferred, I cannot guess why, since it is most likely due to your implementation (i.e. I can't see the code through my crystal ball, it must be uncharged or something ;-) ). But the point is, it is certainly not because of any limmitations of TCP or Boost::ASIO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜