开发者

Have winsock's send function block?

Is it possible 开发者_如何转开发to have winsock's send function block until the packet being sent is received at the other end?

My end goal is to be able to send 5-20mb files while still being able to send small 1kb packets on the same connection. So I was thinking I would have it block until the receiver receives the packet. That way if another small packet is queued it wont be stuck waiting for the rest of the large file to be transferred.


Just use two separate TCP connections. They can even connect to the same host and port, the port number at your end will be different.

Stop-and-wait handshaking over any network (i.e. not loopback) would be miserably slow.


You could send the size of your packages instead

struct MyNetworkPackage {
    int size;
    char* data;
};

if you begin by sending the size, you can deduce on the other side what data belongs to what package.
I've tried to explain winsock in this answer as well.


No. And you don't need to do this.


I am not sure what we would acheive with this.. Mixing traffic on TCP stream won't server any purpose.. Can you explain what exactly u need to do.. Above all, we can never be sure in TCP that the other application has actually received the pkt (it might just be in their tcp buffers)...


It seems that 'send' will block if there is a previous packet still being sent.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜