From nobody Wed Dec 15 16:32:49 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 60E8818DA76A for ; Wed, 15 Dec 2021 16:33:03 +0000 (UTC) (envelope-from bsd-lists@bsdforge.com) Received: from udns.ultimatedns.net (static-24-113-41-81.wavecable.com [24.113.41.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "ultimatedns.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDglf6c5jz4gqs for ; Wed, 15 Dec 2021 16:33:02 +0000 (UTC) (envelope-from bsd-lists@bsdforge.com) Received: from ultimatedns.net (localhost [127.0.0.1]) by udns.ultimatedns.net (8.16.1/8.16.1) with ESMTP id 1BFGWnnE073244 for ; Wed, 15 Dec 2021 08:32:55 -0800 (PST) (envelope-from bsd-lists@bsdforge.com) 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 Date: Wed, 15 Dec 2021 08:32:49 -0800 From: Chris To: freebsd-current@freebsd.org Subject: Re: question on socket server In-Reply-To: References: <1412287950.345.1639565502579@localhost> User-Agent: UDNSMS/17.0 Message-ID: <21aa241b4b1af03e188cc1654393641d@bsdforge.com> X-Sender: bsd-lists@bsdforge.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4JDglf6c5jz4gqs X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; ASN(0.00)[asn:11404, ipnet:24.113.0.0/16, country:US]; local_wl_ip(0.00)[24.113.41.81] X-ThisMailContainsUnwantedMimeParts: N On 2021-12-15 02:55, Piper H wrote: > 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); > } > } > I think it might be easier for you if you have a look at the MILTER interface to Sendmail. There are a myriad milters written for sendmail. The entire milter system is (unix) socket driven. So the examples should prove enlightening? :-) HTH -- Chris > 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 >> ------------------------------ >> >>