[Tutor] creating a server
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Oct 7 14:29:39 EDT 2020
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.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list