From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: HaiJun Zhang Newsgroups: gmane.emacs.devel Subject: Re: Is it possible to change the recv buffer size dynamically for network process or subprocess? Date: Sun, 22 Mar 2020 09:26:37 +0800 Message-ID: References: <1de1c276-1bda-4ada-b3f4-7adaee296628@Spark> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="5e76bed2_6a3dd3e8_6dce" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="8074"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 22 02:27:41 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jFpOu-00020z-Rq for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Mar 2020 02:27:40 +0100 Original-Received: from localhost ([::1]:42454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFpOt-0004DF-UG for ged-emacs-devel@m.gmane-mx.org; Sat, 21 Mar 2020 21:27:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45986) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFpO9-0003o8-AL for emacs-devel@gnu.org; Sat, 21 Mar 2020 21:26:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFpO6-0003cl-UE for emacs-devel@gnu.org; Sat, 21 Mar 2020 21:26:52 -0400 Original-Received: from mail-oln040092255054.outbound.protection.outlook.com ([40.92.255.54]:57071 helo=APC01-HK2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFpO5-0003cB-UK for emacs-devel@gnu.org; Sat, 21 Mar 2020 21:26:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BLJDZHaLvV16fU4EQRxSJi0JUsyONXCINjVY36pib1htfzNhA2YRgyCa5+BXO172KlBn5yy4XuBtGKuwTKmZHw9qCri+Hjrv89hRN8HWnhj/cvUKNGtVlZAElbNbPT3C2rxm6Gz5kKu6vNq/7dPJSAs/FBxni6Np5gFiJYZ/EitLdiWLWcgm7tdxqeiYNmnzCVD7xAdIZHah69rcIPjTG6rCAjJ5/I+S3hI1i66GkXNCk8zzoK6cLlCXg9sbt3W122XNKAtBRPg0dD2jEtyeKKormrc+M5xD7wgQ5SCLKbXNgBfEs1WARUcDb7A6B3jGY5RPb3Ti/IyKr+hKyYjZjg== 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-SenderADCheck; bh=tOFhT2Ft/GpR3/lM6PNpiwBh+Xa6ipvRLmQEA0ERAvw=; b=CzpynjP/C+Xn8JXL2yPtnAcG/xybElzXOLmtcvEoj9orWDUTOe+SOqd6QPkzx/akMeP9fXvXUWawlOCRrOYqgRyW7Nk2dPPp1pLNfKCGaNPpyzL2zFzBoEMZlaF3+7728wAswnPeVrNyaVsaUwn+rfSrWlIZ9sEVeBRiSfXnvIvUxtrbynRkmZjtsgVSiw0aXtS5yEn6YIpVPSwYTqILPBabssZjJlneDxMjuMErVX/yZybs8zsPu1fa2Jm0kez2dPI2DVLqAQPw7ZlCMz6y9FY1KJn/J6poRwgJoFBGYA3IfD05a1wB+YEENGnFmGMNtQu1nqAH4UM+xWqgLm5Hww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tOFhT2Ft/GpR3/lM6PNpiwBh+Xa6ipvRLmQEA0ERAvw=; b=YnYJQd1XsWwdRBa5rIDf33rZ+R8V0gt/AIhespD34Y3NAucetE509S56neywEXxihWM5O3i90ok+8H7s5Jw7sOqo1ieIHVtcoZ+Zx4wJF/tCaQ7/VW/vUiHww1r1EXzX/FFjA+fsZyBfyjXIXYnmLNYJMMiwuHTH6Xu08mgUdYLxyAEgvwg3ExOyqx6yBXcm3EgBL36KmDrQoGzGSVRkbNjXXUtShKnx0jUAuQDJzstTPuw57xEvieuJtzWUsVXp2qxp5rWX7ViA7xl61fqCW3efJEi7Pnz/G668ulZehfHTR7Woc52selsUvNn6JOfsuy2Xw5yq78+hjMU2aislmg== Original-Received: from HK2APC01FT024.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::3a) by HK2APC01HT201.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebc::318) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Sun, 22 Mar 2020 01:26:46 +0000 Original-Received: from PS1PR03MB3606.apcprd03.prod.outlook.com (10.152.248.54) by HK2APC01FT024.mail.protection.outlook.com (10.152.248.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Sun, 22 Mar 2020 01:26:46 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:EDDD833AB5FD6731876A614421CF39DBFD5FFD8718F36CAD500660DFC5B8C2B0; UpperCasedChecksum:9E75DBC0B314067A21EE832FE141B41188F56B455DEDFC2D76BD4F8A756BAF95; SizeAsReceived:8871; Count:49 Original-Received: from PS1PR03MB3606.apcprd03.prod.outlook.com ([fe80::85cb:c430:1173:7716]) by PS1PR03MB3606.apcprd03.prod.outlook.com ([fe80::85cb:c430:1173:7716%5]) with mapi id 15.20.2835.021; Sun, 22 Mar 2020 01:26:46 +0000 In-Reply-To: X-Readdle-Message-ID: 3e7be405-49fc-4db7-93bb-7f438607a52e@Spark X-ClientProxiedBy: HK2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:202:2::22) To PS1PR03MB3606.apcprd03.prod.outlook.com (2603:1096:803:4e::17) X-Microsoft-Original-Message-ID: <3e7be405-49fc-4db7-93bb-7f438607a52e@Spark> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from [192.168.1.150] (1.196.184.53) by HK2PR0401CA0012.apcprd04.prod.outlook.com (2603:1096:202:2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Sun, 22 Mar 2020 01:26:45 +0000 X-Readdle-Message-ID: 3e7be405-49fc-4db7-93bb-7f438607a52e@Spark X-Microsoft-Original-Message-ID: <3e7be405-49fc-4db7-93bb-7f438607a52e@Spark> X-TMN: [lc//iunr/qqtXk9VEmSGsFO9BSsCVFoH] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9533b02e-1b56-40eb-cb60-08d7ce0015d1 X-MS-TrafficTypeDiagnostic: HK2APC01HT201: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 10eQXxssWIIXgXd0vQrsi1aA19v3EF1oym7h3ZzxHNbxtUVoSbPEEIIaJOe8WUBQT5ZFHBCxmYBBcc+EHN9gZ4aHQ7fsBxhX1d61tbGtcQtWBeWKZKFavLRiODe3/0xj0KtRQxTCB1C2xvqstFvCQ+Px7pLKh1yPrLR5D+68/mskCXRgWhoTJ/NrF+Spa7WU X-MS-Exchange-AntiSpam-MessageData: RvH2bwqac8VUR6uIYrqxIFoCHiJL71wahHZ8fPN9zkhoI338J8P5BHUxyMFx8P9iKK0t87SimevyYzVVsi1QWUOPOKsCsf8glvY4+bTIuVE1l+yJCyQrhJILVI0tQoSy+T5nKujxJ90A4U7t3BXRnQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9533b02e-1b56-40eb-cb60-08d7ce0015d1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2020 01:26:45.9825 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2APC01HT201 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.92.255.54 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245656 Archived-At: --5e76bed2_6a3dd3e8_6dce Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =E5=9C=A8 2020=E5=B9=B43=E6=9C=8821=E6=97=A5 +0800 PM8:10=EF=BC=8CRobert = Pluim =EF=BC=8C=E5=86=99=E9=81=93=EF=BC=9A > > > > > > On Sat, 21 Mar 2020 11:01:05 +0800, HaiJun Zhang said: > > HaiJun> =46or example, I have binary message format like this: > HaiJun> 1. It has a four-bytes header and payload. > HaiJun> 2. The four-bytes header is the payload size of the message. > > HaiJun> =46irst I want to set the size of the recv buffer to 4. After t= he four > HaiJun> bytes arrived, I parse them and get the size of the payload. Th= en I > HaiJun> set the size of the recv buffer to the size of the payload to r= ecv the > HaiJun> payload. > > Why bother=3F You=CA=BCre going to have to handle partial recv for the > payload anyway, so you might as well do it from the start. > > Robert I want to do flow control, because too many data may cause UI unresponsiv= e. Set the recv buffer size to 4, and if I don=E2=80=99t fetch the four b= ytes, please don=E2=80=99t receive more data. If the size (In the four by= tes header) is too big, ask the user if the message should be received. --5e76bed2_6a3dd3e8_6dce Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
=E5=9C=A8 2020=E5=B9=B43=E6=9C=8821=E6=97= =A5 +0800 PM8:10=EF=BC=8CRobert Pluim <rpluim@gmail.com>=EF=BC=8C= =E5=86=99=E9=81=93=EF=BC=9A
On Sat, 21 Mar 2020 11= :01:05 +0800, HaiJun Zhang <netjune@outlook.com> said:

HaiJun> For example, I have binary message format like this:
HaiJun> 1. It has a four-bytes header and payload.
HaiJun> 2. The four-bytes header is the payload size of the message.

HaiJun> First I want to set the size of the recv buffer to 4. After the = four
HaiJun> bytes arrived, I parse them and get the size of the payload. The= n I
HaiJun> set the size of the recv buffer to the size of the payload to re= cv the
HaiJun> payload.

Why bother? You=CA=BCre going to have to handle partial recv for the
payload anyway, so you might as well do it from the start.

Robert 

I want to do flow control, because too many data may cause UI unrespon= sive. Set the recv buffer size to 4, and if I don=E2=80=99t fetch the four = bytes, please don=E2=80=99t receive more data. If the size (In the four byt= es header) is too big, ask the user if the message should be received.

--5e76bed2_6a3dd3e8_6dce--