From nobody Tue Nov 15 03:42:18 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NBBnp02Yzz4dDMK for ; Tue, 15 Nov 2022 03:42:22 +0000 (UTC) (envelope-from M.ALI023@hotmail.com) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12olkn2060.outbound.protection.outlook.com [40.92.23.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "DigiCert Cloud Services CA-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NBBnn0JNfz4Mgq for ; Tue, 15 Nov 2022 03:42:21 +0000 (UTC) (envelope-from M.ALI023@hotmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=hotmail.com header.s=selector1 header.b=nTiRvWb5; spf=pass (mx1.freebsd.org: domain of M.ALI023@hotmail.com designates 40.92.23.60 as permitted sender) smtp.mailfrom=M.ALI023@hotmail.com; dmarc=pass (policy=none) header.from=hotmail.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C15eF3msDf5dnSZ3Cp2QHfaUJn48JmxencnChWu6K6ObhQGnHfXDHuUoPffv84uj7hqkaMJ4qMR7K7S+x2DB1TkIZp/XiVYqUqh+JKvaNDLTtx0r8HYCWM0JbK3RGL2mj4hBqqcpIfJV1CXquA5zr5/GTliBSyiguwgN6SFbAYiDFfgdBcp0MAfrRfnf+R8IZkm1exrWm7FA2k0vQNQKDJXmDAN8yafIU25P68dBdCbuNJdjfsn3oZ9mECd+CMedd/RcbA8IgCwQ6XaaOf7w3GpRdG4ImN7zoettNyCQQ6Sv23vUVPwvIEs8nAH1uQEq8/q8lHkCJbi/GrJpSzhZcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lzff4WaUb9EbE7oBW+j4hQuNiPy8PP+2ZZasOar4ogs=; b=R/eKH6yTnvNdtaoxR5TjUDTgaSUPet/PKZVhyv+9Qz1WKxhq+YAOE0iECL3sgzug+s94fXCJsy2KwD3j/l7RYD8XBLBuudAZHYEkaNps2BrEA80X4r8vs6vb6UmAF4Hs429kEaXkURYZdpOiyP189GJQv5zvF4BwJc6PrXs7Z4bC7k8/GTmcr0bCStiWviwLEqTdvvdJsWcoi5Q+aDc6UQ06TxR8o3U9NKvwY6iofSokNB2MriZDxMpRblymJ8hkqPOHP1jaTciSiJDxb56hOLa5bAoFbtsihRG+wnPkPO94+SltbrfkWZQulNkhgKglSfND/9fsEQyhDILGawLbMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lzff4WaUb9EbE7oBW+j4hQuNiPy8PP+2ZZasOar4ogs=; b=nTiRvWb5S80QJmXK5Z1rvoeIohma05eBl/lDqS/3LBUbjAmeLTF7fgS0dzlA3/3zanymTUVFX2GkhnyHJrDZBfTFat5qwAhwhgunQqLiYyKu4wo9pPVwqGdrIvNviO1BrPZAmVOa5kQGORPpnF/4kMqN9rCm0UOjMmrQ7VFhnbjsqHUZ78r3k1ibz9TWDwjHWBWvTGk63QgQ/F53hRNwbOK7FOjsA6QbgKwIkgoX6OVIHsGi/DQP+zHe5lP1CZyKsVbZBOWPxi2MeMyYeOvem5ltxgrP/kVmxifCZTArUtkT74RwMW00JnTPEhU/JfvxbiN30DdJU6pjgrlyKMztjg== Received: from DM6PR07MB6074.namprd07.prod.outlook.com (2603:10b6:5:18c::25) by SA1PR07MB8433.namprd07.prod.outlook.com (2603:10b6:806:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 03:42:18 +0000 Received: from DM6PR07MB6074.namprd07.prod.outlook.com ([fe80::54d6:12d:c4b7:24fd]) by DM6PR07MB6074.namprd07.prod.outlook.com ([fe80::54d6:12d:c4b7:24fd%7]) with mapi id 15.20.5813.017; Tue, 15 Nov 2022 03:42:18 +0000 From: Muhammad Ali To: "freebsd-questions@freebsd.org" Subject: SO_SNDLOWAT and write(2) return value Thread-Topic: SO_SNDLOWAT and write(2) return value Thread-Index: AQHY+KK8bYYtfZLbLk2Lr1Vu/dsl4Q== Date: Tue, 15 Nov 2022 03:42:18 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-tmn: [eWDZTdQQmZLX0VrYnY2MhXXPKyfwU5H0hdamo3dTUH/Na105n2eHQn31YgE/43xcVGxMYnmiRtk=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR07MB6074:EE_|SA1PR07MB8433:EE_ x-ms-office365-filtering-correlation-id: d7ac6f5c-d10e-4754-3ae9-08dac6bb650d x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: j/mnuVBK9oA+gLMFAKw62zxOxttWo4SQqE3T2mrbgbcdLFwtWk+ElmJgW3HMEOWloYK0DOUmzk42TEpnObaxisWjy9fvJFt3KRSIC1mrK+JE39XMSLBJB+sQzwyiIIuExtyOh0Yu57tVMMl3t2dypw8YvBRsvHJBhsQGJP1vfqE3scNTl8dwL/HOcHisbUNxePXAaD6/Tx0Fl7TI3fgaqTEmbeEWC2BmpNrtt571PHUJctPTq8g705WQPvoEn7UW4QYHThyHwtFYWomTCACmFXXwP6E70vrTa8E3QbOrSpliDnLrp27eUFkiOGc8RkI4WR/rXMV5TboHQvrC5MQQpu1DVNdSwkk9okQ3+RYckaqrwctIzkl06SDtI8CUc4DI2AHLoQFBRhDrkeLVSEGaYQotM56i0fUs28noBZU5DzjXLEp3KR0/2T2q4iBMntrB/ny30m8RKY5CkPl0/9drrXO1okddErr8nMfo+zx7x94oRLAUrFlUOUOnSs6bWGE/a15obLqgF59j9g5rgyUAcHCa8Iti0qcScCfmePizDzm0mviqBrDwaRM61Pj7oXyVe2WcnYPzKHNmlhDZl/YBHtFfoUvDwqMFYeVUoLJDcsIQCGLG3V8EB3NdROaPecbRNmAKeSt+05r0LTIE7aRGyaPH49C+W9MACQXxQbGi0+69Vk2g4XlHcbMS5ljwtnXm x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?U8uY7zB7NdfAxaKKVF3fIskzuR/iDvEZ0Z9jvD0UFEdhpQKZOOBkSsZAX7?= =?iso-8859-1?Q?7my4yAzAuo7c7I/KPAFNZrILKL0/oSxehTIU58y/y97QQPHSmdSjXHz8ta?= =?iso-8859-1?Q?aBRS+EgN9RLShslpotsS4VW94A26WgLd/AY62BErGgdmclIRpaGXfbFqYx?= =?iso-8859-1?Q?Xk2fduVIzON0v5LKJWMxIlhqf111CrFP7twKgkv6hsCdAmz59acPOJQyP1?= =?iso-8859-1?Q?b7BL7b7SljZxkP440gGKj7P2NVes/O0suEkQnX7hOFOtgL6RyKvnMJPM+9?= =?iso-8859-1?Q?g/NW1OnkU675c0baJ1Ze3g/Lz8lO3eKQBidtkPMq0Nxuvx6UNdIsSxiWJ/?= =?iso-8859-1?Q?+WWTOM7uYIPqn20dasv7sKr2w/YVuQg5GjMeePE9s9RzPwqs57ez4O5sup?= =?iso-8859-1?Q?gCPGc5yzaHbYskJkEt1KnnLZ4jC8/O/WAkXYkMlK74rQiBKF0K/1RAVCtO?= =?iso-8859-1?Q?KcI1irjWEzHTPssNBHZJp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?Q?6YBam3i40YILCSte6sGtjGTnobP7HW8g=3D=3D?= Content-Type: multipart/alternative; boundary="_000_DM6PR07MB6074128A7B4A8F8905946731D9049DM6PR07MB6074namp_" List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-5fbaf.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR07MB6074.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: d7ac6f5c-d10e-4754-3ae9-08dac6bb650d X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2022 03:42:18.2271 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR07MB8433 X-Spamd-Result: default: False [-2.72 / 15.00]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector9901:i=1]; NEURAL_HAM_SHORT(-0.72)[-0.724]; DMARC_POLICY_ALLOW(-0.50)[hotmail.com,none]; R_DKIM_ALLOW(-0.20)[hotmail.com:s=selector1]; R_SPF_ALLOW(-0.20)[+ip4:40.92.0.0/15]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:8075, ipnet:40.80.0.0/12, country:US]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_EQ_ADDR_ALL(0.00)[]; FREEMAIL_ENVFROM(0.00)[hotmail.com]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; RCVD_IN_DNSWL_NONE(0.00)[40.92.23.60:from]; DKIM_TRACE(0.00)[hotmail.com:+]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[40.92.23.60:from]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FREEMAIL_FROM(0.00)[hotmail.com]; DWL_DNSWL_NONE(0.00)[hotmail.com:dkim] X-Rspamd-Queue-Id: 4NBBnn0JNfz4Mgq X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N --_000_DM6PR07MB6074128A7B4A8F8905946731D9049DM6PR07MB6074namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Consider the following scenario: 1. Socketpair(2) returns two connected sockets: sp[0] and sp[1] 2. Setsockopt(2) the option SO_SNDLOWAT for sp[1] to 10 bytes 3. Write(2) to sp[1] with exactly 10 bytes Is it ever possible for write(2) to return less than 10 bytes in this case?= Generally, I would think yes since setting SNDLOWAT only checks if there's= enough buffer space for 10 bytes and if there is then we start writing, bu= t the write may get interrupted and return 6 bytes, for example. I have read APUE third edition page 624 and the man page for setsockopt(2) = and it seems the two are conflicting or I am not understanding correctly. T= o quote APUE: "The minimum amount of data in bytes to transmit in a send ca= ll", see Page 624, Figure 16.21. As you can see this suggests that less tha= n 10 bytes will never be returned but the FreeBSD setsockopt(2) man page su= ggests that less than 10 bytes can be returned. Which is correct? BTW, I don't think SAR meant the send(2) call (in the above quote) rather h= e just wrote send as a generic term to mean write/send/etc... --_000_DM6PR07MB6074128A7B4A8F8905946731D9049DM6PR07MB6074namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi, 
Consider the following scenario:
  1. Socketpair(2) returns two connected sockets: sp[0] and sp[1]
  2. Setsockopt(2) the option SO_SNDLOWAT for sp[1] to 10 bytes=
  3. Write(2) to sp[1] with exactly 10 bytes
  4. Is it ever possible for write(2) to return less than 10 bytes in= this case? Generally, I would think yes since setting SNDLOWAT only checks= if there's enough buffer space for 10 bytes and if there is then we start = writing, but the write may get interrupted and return 6 bytes, for example.

I have read APUE third edition page 624 and the man page for setsockopt(2) = and it seems the two are conflicting or I am not understanding correctly. T= o quote APUE: "The minimum amount of data in bytes to transmit in a se= nd call", see Page 624, Figure 16.21. As you can see this suggests that less than 10 bytes will never be returne= d but the FreeBSD setsockopt(2) man page s= uggests that less than 10 bytes can be returned.

Which is correct?

BTW, I don't think SAR meant the send(2) call (in the above quote) rather h= e just wrote send as a generic term to mean write/send/etc...
--_000_DM6PR07MB6074128A7B4A8F8905946731D9049DM6PR07MB6074namp_--