mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Catalin Drula <catalin.drula@imag.fr>
Cc: linux-kernel@vger.kernel.org
Subject: Re: AF_UNIX sockets: strange behaviour
Date: Wed, 17 Nov 2004 23:42:52 +0100	[thread overview]
Message-ID: <81b0412b04111714426d82cab2@mail.gmail.com> (raw)
In-Reply-To: <Pine.GSO.4.33.0411171618260.8987-100000@horus.imag.fr>

On Wed, 17 Nov 2004 16:29:14 +0100 (CET), Catalin Drula
<catalin.drula@imag.fr> wrote:
> I have a small application that communicates over Bluetooth. I use
> connection-oriented UNIX domain sockets (AF_UNIX, SOCK_STREAM) to
> communicate between the applications's threads. When reading from
> one of these sockets, I get a strange behaviour: if I read all the
> bytes that are available (13, in this case) all at once, it's fine;
> however, if I try to read in two smaller batches (say, first time
> 6, and second time 7), the first read returns (with the 6 bytes), but
> the second read never returns.

2.6.9, works. Could you post your code?

#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>

int main(int argc, char **argv)
{
    char buf[13];
    int s[2];
    if ( socketpair(AF_UNIX, SOCK_STREAM, 0, s) < 0 )
    {
	perror("socketpair");
	return 1;
    }
    if ( fork() == 0 )
    {
	close(s[0]);
	write(s[1], "023456789012", 13);
	read(s[1], buf, 1); /* wait for parent */
    }
    else
    {
	close(s[1]);
	if ( read(s[0], buf, 6) != 6 )
	    perror("6");
	if ( read(s[0], buf, 7) != 7 )
	    perror("6");
	close(s[0]);
    }
    return 0;
}

  parent reply	other threads:[~2004-11-17 22:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-17 15:29 Catalin Drula
2004-11-17 16:09 ` linux-os
2004-11-17 18:11 ` Stephen Hemminger
2004-11-17 22:42 ` Alex Riesen [this message]
2004-11-18 13:24   ` Catalin Drula
2004-11-17 16:23 Catalin Drula
2004-11-17 16:41 ` linux-os

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=81b0412b04111714426d82cab2@mail.gmail.com \
    --to=raa.lkml@gmail.com \
    --cc=catalin.drula@imag.fr \
    --cc=linux-kernel@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

Powered by JetHome