Operating System - OpenVMS
1748195 Members
4359 Online
108759 Solutions
New Discussion юеВ

Windows socket client drops the last byte of every packet

 
Oswald Knoppers_1
Valued Contributor

Re: Windows socket client drops the last byte of every packet

Yes but missing some byte in the middle of the stream seems unlikely.

This points to an error in the receiving application. Maybe overlapping buffers or something.

Oswald
Hoff
Honored Contributor

Re: Windows socket client drops the last byte of every packet

Presume that a read receives a torn "message" (as is entirely permissible within TCP) and, for grins, assume that the tear is either in front of or within the word-length length field. Or presume that the reader now gets a few bytes that didn't make it over with the previous "message" read. Where does that leave the rest of the code?

If you want to operate with the envisioned reliable datagram transport via TCP, then you get to implement your own "packet" disassembly code, and you have to look at and slide a window based on how many bytes each read has received.

This is one of various considerations and problems that arise with socket programming that have been solved before; sockets are among the oldest and most primitive and problematic interfaces. Stuff like zeromq is definitely a friend here, and that use then frees you up to add more value for your customers.
tsgdavid
Frequent Advisor

Re: Windows socket client drops the last byte of every packet

Thanks for everyones comments. I have a better understanding of how this should work, but I do not understand why I am having a problem. I don't see any explanation in my client program when I can do a single QIOW on the server and on my first call to Receive on the client, I get the entire stream but with missing bytes. There are no more bytes to read in the stream at this point.

Having said that, I have an application that is functioning well by splitting the sent message into two separate QIOWs. I realize that this should have no bearing on what I receive, but it does. I am able to control which bytes get dropped in this manner.

Seeing no other explanation at the moment, I will call this good enough for now. Thanks, again.