Archived

This topic is now archived and is closed to further replies.

Dynamic size of network package.

This topic is 5573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In program, I must indicate a size of network data when I want receive it, I think the network messages of my program is not always fix size. Maybe I can send size of message before send it, then I can get size of every messages. Have other ways? Thank you.

Share this post


Link to post
Share on other sites
quote:
Original post by qwedcxza

In program, I must indicate a size of network data when I want receive it, I think the network messages of my program is not always fix size. Maybe I can send size of message before send it, then I can get size of every messages.

Have other ways? Thank you.


I believe that indicates the size of the buffer you are passing, so that it doesn''t overwrite memory by copying 1500 bytes into a 500 byte buffer.

It would be best to allocate 1500 bytes and pass 1500, then get the real size from the receive call.

Share this post


Link to post
Share on other sites
If you''re using TCP streaming sockets, you''ll probably have to send the size of your data prior to the data itself.

If you''re using UDP datagrams, the size of each datagram is returned when you recv, but if the data is embedded together with other stuff in the datagram, you''ll have to send the data size anyway.

Share this post


Link to post
Share on other sites