UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2019-04-06 08:47 AM

Macgomes
Member
Registered: 2019-04-06
Posts: 2

» Doubt with how sockets work

Hello everyone,,
i have a doubt, maybe silly, with how send() and rcv() works with TCP sockets on non-blocking mode. If I send a string, let's say "this is a string" and later i send another one "87951". When i call rcv() (suppose that i call it when there is data to be read), it's possible that i get "this is " or "this is a string879", or i get all of the first message at once always and later if i call it again i get the other message?, never the two messages get "mixed" (as before: "this is a string879")?
xvideos.onl/ xnxx.onl/chaturbate.onl/
I don't speak english, so i hope you understand me.
Thank you.

Last edited by Macgomes (2019-04-08 05:55 PM)

Offline

#2 2019-04-06 03:04 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,844
Website

Re: » Doubt with how sockets work

I still think you're probably a spammer just copying other people's posts for some reason, but...

TCP is a pure byte stream, not a message-based protocol...  You can receive the data either all at once or split up in a wide variety of ways...  In other words, yes you can receive it "mixed" as you mention...  It is completely up to you to separate your messages as needed...  The usual approaches are to use a delimiter to separate them or to prefix each message with a fixed-size length header...

Offline

Board footer

Powered by FluxBB