linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John T. Williams" <jtwilliams@vt.edu>
To: jtwlliams@vt.edu
Cc: linux-c-programming@vger.kernel.org
Subject: Re: socket send and recv
Date: Thu, 7 Aug 2003 18:03:35 -0400	[thread overview]
Message-ID: <001f01c35d2f$d48ca8e0$ed64a8c0@descartes> (raw)
In-Reply-To: 20030807114057.GA19378@lsd.di.uminho.pt


I common delimiter used by many protocols is either a single \n\r for
messages which are known to me less then on line (ie have not \n in them) or
a \n\r.\n\r for messages that could have multiple lines




----- Original Message ----- 
From: "Luciano Miguel Ferreira Rocha" <luciano@lsd.di.uminho.pt>
To: "ronkhu" <ronkhu@ntsp.nec.co.jp>
Cc: "Earl Lapus" <lapuz.rl@mp.ncos.nec.co.jp>; "Lejanson C. Go"
<g_l-go@tmg99.ntes.nec.co.jp>; <linux-c-programming@vger.kernel.org>
Sent: Thursday, August 07, 2003 7:40 AM
Subject: Re: socket send and recv


> On Thu, Aug 07, 2003 at 06:46:18PM +0800, ronkhu wrote:
> > i have a client program which sends a sequence of bytes everytime
> > anything(plus carriage return)  is inputted into STDIN...
> >
> > but the problem lies in the receiving end of the socket connection...
> > with a single call of the recv() function, multiple messages sent by the
> > client are concatenated into one stream..
> Yes, STREAM sockets have no knowledge of messages, but DGRAM do (but
> are unreliable).
>
> So you need to have a way to know what is a single message, either by
> using delimiters (like \n) or by using headers, with the length of the
message.
> (Or use DGRAM sockets.)
>
> Also, you can use the TCP_NODELAY socket(7) option to force the data to
> be sent immediately, but there's no gaurantee it won't be buffered at the
> receiver.
>
> Regards,
> Luciano Rocha
> -
> To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


      reply	other threads:[~2003-08-07 22:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-07 10:46 socket send and recv ronkhu
2003-08-07 11:40 ` Luciano Miguel Ferreira Rocha
2003-08-07 22:03   ` John T. Williams [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001f01c35d2f$d48ca8e0$ed64a8c0@descartes' \
    --to=jtwilliams@vt.edu \
    --cc=jtwlliams@vt.edu \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).