From nobody@FreeBSD.ORG Wed Aug  4 08:33:24 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id C62C9153C4; Wed,  4 Aug 1999 08:33:23 -0700 (PDT)
Message-Id: <19990804153323.C62C9153C4@hub.freebsd.org>
Date: Wed,  4 Aug 1999 08:33:23 -0700 (PDT)
From: ypoeluev@certicom.com
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: Outgoing data with stream sockets on FreeBSD
X-Send-Pr-Version: www-1.0

>Number:         12964
>Category:       i386
>Synopsis:       Outgoing data with stream sockets on FreeBSD
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug  4 08:40:01 PDT 1999
>Closed-Date:    Tue Aug 10 08:56:48 PDT 1999
>Last-Modified:  Tue Aug 10 08:58:12 PDT 1999
>Originator:     Yuri Poeluev
>Release:        2.2.5
>Organization:
Certicom Corp.
>Environment:
FreeBSD certicom.com 2.2.5-RELEASE FreeBSD 2.2.5-RELEASE #0: Thu Jun  4 16:01:24 EDT 1998     root@:/usr/src/sys/compile/GALOIS  i386

>Description:
Hi,
I'm using stream sockets for client and server communications
and have found a problem with data sent from FreeBSD to
any other platform (Solaris,WinNT,BSDi,etc). When the data
has a size in the range 101-207 bytes, the receiver gets
only 100 bytes. By the way, I was using blocking sockets
and if I tried to read data again on the receiver side (other then FreeBSD),
read operation can't succeed because apparently no data left for reading.
There might have been some settings when we built our kernel,
but I couldn't find anything.
Your help will be appretiated.
Thanks.
>How-To-Repeat:
On the server side (FreeBSD)
=====================================
theSocket = socket(AF_INET, SOCK_STREAM, 0);
theAddress.sin_port = htons((unsigned short)kPort);
theAddress.sin_family = AF_INET;
bind(theSocket, (struct sockaddr *)&theAddress, sizeof(theAddress));
listen(theSocket, 5);
len = sizeof(theAddress);
hisSocket = accept(theSocket,(struct sockaddr*)&theAddress, &len);
send(hisSocket,buffer,105,0);
...


On the client side (any other platform)
=====================================
s = socket(AF_INET, SOCK_STREAM, 0);
ent = gethostbyname(kServer);
addressRec.sin_port = htons((unsigned short)kPort);
addressRec.sin_family = AF_INET;
addressRec.sin_addr = *((struct in_addr *)ent->h_addr);
connect(s, (struct sockaddr *) &addressRec, sizeof(addressRec));
l=recv(s,buffer,sizeof(buffer),0); /* only 100 bytes read */
...
>Fix:


>Release-Note:
>Audit-Trail:

From: adrian@freebsd.org
To: freebsd-gnats-submit@freebsd.org
Cc: ypoeluev@certicom.com
Subject: Re: i386/12964 Outoging data stream sockets on FreeBSD
Date: Tue, 10 Aug 1999 21:53:58 +0800

 This was fixed in src/sys/kern/uipc_socket.c v1.41 .. 
 your best bet is to either hand patch the kernel and see if it works,
 or just upgrade to a later release.
 
 This PR can be closed. Someone?
 
 
 Adrian
 

From: Yuri Poeluev <ypoeluev@certicom.com>
To: adrian@freebsd.org
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: i386/12964 Outoging data stream sockets on FreeBSD
Date: Tue, 10 Aug 1999 11:42:33 -0400

 This is a multi-part message in MIME format.
 --------------64BFA819B7F47C6131D8295A
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Hi Adrian,
 
 Thanks for your reply. I have found a solution.
 Apparently, stream sockets do not guarantee
 that a packet at the application level will be
 delivered in one piece. It was wrong for
 me to say that I was losing data, that wasn't the case.
 The application-sender was sending a
 packet of 150 bytes, for instance,
 first time the application-receiver got 100 bytes and
 second time it got the rest 50 bytes. Anyway, my impression
 of stream sockets was that if an application sends a packet,
 an application-receiver would get the same
 packet or bigger one if more data is available
 from UDP. I guess, I was wrong to assume
 that stream sockets will not break the
 packets at the application level. But,
 it's still interesting that only on FreeBSD stream
 sockets break packets (101-207-byte long)
 into two. In my case, I'd rather use packet
 oriented sockets (datagram), that guarantees
 packets delivery with possible loss of packets though.
 Some people were saying that you can send a
 delimiter (CR) to separate packets inside
 the data stream, but if an application
 sends binary data this is not a good choice of course.
 It seems that an application cannot have
 reliable and packet oriented protocol at the
 same time.
 
 Sorry for taking your time.
 Please, close this PR.
 
 Thanks,
 Yuri Poeluev
 Certicom Corp.
 
 
 --------------64BFA819B7F47C6131D8295A
 Content-Type: text/x-vcard; charset=us-ascii;
  name="ypoeluev.vcf"
 Content-Transfer-Encoding: 7bit
 Content-Description: Card for Yuri Poeluev
 Content-Disposition: attachment;
  filename="ypoeluev.vcf"
 
 begin:vcard 
 n:Poeluev;Yuri
 x-mozilla-html:FALSE
 org:Certicom Corp
 adr:;;200 Matheson Blvd. W.;Mississauga;ON;L5R 3L7;Canada
 version:2.1
 email;internet:ypoeluev@certicom.com
 note:Web site: http://www.certicom.com
 x-mozilla-cpt:;0
 fn:Yuri Poeluev
 end:vcard
 
 --------------64BFA819B7F47C6131D8295A--
 
 
State-Changed-From-To: open->closed 
State-Changed-By: adrian 
State-Changed-When: Tue Aug 10 08:56:48 PDT 1999 
State-Changed-Why:  
Submitter reports this can be closed. 
>Unformatted:
