From nobody Wed Dec 15 10:55:17 2021 X-Original-To: freebsd-current@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 4999818E4BBB for ; Wed, 15 Dec 2021 10:55:29 +0000 (UTC) (envelope-from potthua@gmail.com) Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDXG90GKjz4mw3 for ; Wed, 15 Dec 2021 10:55:29 +0000 (UTC) (envelope-from potthua@gmail.com) Received: by mail-ua1-x933.google.com with SMTP id w23so40187998uao.5 for ; Wed, 15 Dec 2021 02:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9IqojWJtIeYUwdYWRNnZQGtDPU79UqZ90K3IfSvaX78=; b=W+HO4Lb1QeZHUTPfzDCx6yKrEn0BH2rC7ftZKzibn53GhZwJpP4jov5BFst+9kAoOp v/Fc39k4/orfEovr7oWdtDOUYNFPQfifikZ6malkfm3ornp5mI+hsjJnK/h1fBWoQPKb jFfZeAhg2TViaH+tAT5MgXKvr5mEYgpifi2XEJVBp04+YEl3p1w6hOmYqrkp66cEL1k9 a+M1McMfYJLXuGxoF+WdHJ9x2Bn9oGGU0VpPslWFpOG6TCrCt0ynL8Z6xkLRCvSOmH8B 2I+p0JJqxgjuomqd22+QhBPsLg/b+E0b/MHnzgICuaCZb67CLgucd1cno3StNWazDwjY BnXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9IqojWJtIeYUwdYWRNnZQGtDPU79UqZ90K3IfSvaX78=; b=4wcHkYnheUP1s0VA6D36GkEW0SqrBAVFzPAqaU2qh4yJLoEjMa4HiECznuO7DpSM98 uvFhhre2KOr+MVe/jwaKEjczh0PK/U0PzcQ/9uSc60IyDSsy3UzjpuM8PeQ8Hs0/ZxXm VmPWNEFqEcsvVDtrV5awvSaNAnguPVdMvdnE6REW9SfZ3pTPbin4Sws/dZ0b0sxBBgNE nPIAz17MFJ3Wbf/gUsu7uLt6Qq/mQqp464YZDwnPIkcGTWYKGIN4CLRKscZ3WSv6V8be moX7ilq//h+41RDsJFC3o3VxyARgj0JPQLlS0YOOu9uh9JOSDYfrJNRDquadIxFafJw6 pUbQ== X-Gm-Message-State: AOAM530yzvMipz9Vpwg5WMi4PxCtw1MvbvGCTvJQ+5hk+QpEK4uhBiUB j0u54yfm7zsvEzCPochu5Lg26ZhXAK+K3cGXA1CKnfNqnbpidbtU X-Google-Smtp-Source: ABdhPJyE7XYmB8QheLRnq065XouOxxR7LZnyM5EHFsXAtcpJSw3T2tG4G58v6HCSN3+DGTItm7Kjp5g9cmP3QO8wGzI= X-Received: by 2002:ab0:4911:: with SMTP id z17mr8957720uac.91.1639565728448; Wed, 15 Dec 2021 02:55:28 -0800 (PST) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 References: <1412287950.345.1639565502579@localhost> In-Reply-To: <1412287950.345.1639565502579@localhost> From: Piper H Date: Wed, 15 Dec 2021 18:55:17 +0800 Message-ID: Subject: Re: question on socket server To: Ronald Klop Cc: freebsd-current@freebsd.org Content-Type: multipart/alternative; boundary="000000000000d4878a05d32d2481" X-Rspamd-Queue-Id: 4JDXG90GKjz4mw3 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: Y --000000000000d4878a05d32d2481 Content-Type: text/plain; charset="UTF-8" But I write this program to listen on port 6666 who sends a random str to the socket every 0.25 second. And there is no client connecting to the port. The server just runs there without problem. :( So I am not sure enough... use strict; package MyPackage; use base qw(Net::Server); my @fruit=qw( ... ); sub process_request { my $self = shift; $| = 1; my $max = scalar @fruit; while (1) { my $id1 = int(rand($max)); my $str = $fruit[$id1]; print "$str\015\012"; select(undef, undef, undef, 0.25); } } MyPackage->run(port => 6666, ipv => '*'); On Wed, Dec 15, 2021 at 6:51 PM Ronald Klop wrote: > Hi, > > Just try it! > > I think you will get an error that you are writing to a not-connected > socket. > From "man 2 write": > " [EPIPE] An attempt is made to write to a socket of type > SOCK_STREAM that is not connected to a peer socket." > > See also "man 2 send" and "man 2 socket" for a lot more information. > > So it depends a bit on the type of socket you created. > > Regards and happy hacking, > Ronald. > > > > *Van:* Piper H > *Datum:* woensdag, 15 december 2021 07:52 > *Aan:* freebsd-current@freebsd.org > *Onderwerp:* question on socket server > > Hello > > I have little knowledge about socket programming. > I have a question that, if I have made a socket server, listening on a > port. The server prints data to the socket, but there is never a client > connection to the port, and the data is never consumed. What will happen to > the server then? will the OS kernel be flushed by junk bytes? > > Thanks for your help. > Piper > ------------------------------ > > --000000000000d4878a05d32d2481--