[Tutor] creating a server
nathan tech
nathan-tech at hotmail.com
Wed Oct 7 15:13:03 EDT 2020
Exactly!
that's what part of my question was, really :) how does one go about
verifying all data was received?
recv(2000000)
seems a bit ludicrous to me and besides, what you don't want to do is
receive an object and then half of the next one, too!
Thanks
On 07/10/2020 19:29, Alan Gauld via Tutor wrote:
> On 07/10/2020 19:13, nathan tech wrote:
>> I certainly have and was going to base my code around it but was unsure
>> if sockets could handle the passing of objects?
> sockets only care about bytes, they know nothing about data types.
> That's up to you! You will need to choose a format to encode
> your data in the message - JSON or YAML or XML or ASN.1 etc.
> Then use a parser to pack/unpack the high level into and out
> of the data stream.
>
> But your own suggested server was still using sockets and reading bytes.
>
> You had a recv(1024) call. That reads 1024 bytes. What would happen
> if your "object" was 1500 bytes long? You'd only have part of it to process.
>
More information about the Tutor
mailing list