简体   繁体   中英

UDP Socket Async Receive

I deliberately issue socket.BeginReceiveFrom call and pass the buffer of 16 bytes, despite that I know that the other side send messages of about 2,000 bytes. I do that deliberately because I just want to read the header of 16 bytes first and then issue a second receive call that will read the payload which is of variable length. As you may guess the header includes 4 bytes that indicates the payload length.

That said, I get an exception that says that the buffer is not big enough to receive the message... How come?

Thats not possible, udp are datagrams instead of streaming. You cannot read messages partial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM