From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 29 07:33:59 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D041816A403 for ; Wed, 29 Nov 2006 07:33:59 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2816243E82 for ; Wed, 29 Nov 2006 07:31:28 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id kAT5fWMG020554; Wed, 29 Nov 2006 08:41:32 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id kAT5fUwN020553; Wed, 29 Nov 2006 08:41:31 +0300 (MSK) (envelope-from yar) Date: Wed, 29 Nov 2006 08:41:30 +0300 From: Yar Tikhiy To: "Devon H. O'Dell" Message-ID: <20061129054130.GH96853@comp.chem.msu.su> References: <456CA68E.7090207@u.washington.edu> <9ab217670611281324y7e6b9d69g7f8843504b2fbd8d@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9ab217670611281324y7e6b9d69g7f8843504b2fbd8d@mail.gmail.com> User-Agent: Mutt/1.5.9i Cc: freebsd-hackers@freebsd.org, Garrett Cooper Subject: Re: Single UDP sockets : duplex capable? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Nov 2006 07:33:59 -0000 On Tue, Nov 28, 2006 at 04:24:08PM -0500, Devon H. O'Dell wrote: > 2006/11/28, Garrett Cooper : > >Hello, > > > > Just wondering, abstractly.. > > Both sides can read from and write to the socket file descriptor. > You'll need to develop a protocol to determine when either given side > is expecting to receive or to send data (if both sides sit around in > read(2), you're not going to get much done) :) ... and if you want asynchronous conversation, i.e., data coming anytime, consider using non-blocking sockets with select(2), poll(2), or kqueue(2). The particular choice depends upon the requirements on the portability and performance of the application. If you target at as much systems as possible, using a ready-made wrapper library such as libevent can be an option. > > ------------------------- > >| A -[socket (UDP)]-> B | > > ------------------------- > > > > A creates a UDP socket (call it 's1') to talk to B. > > > > Can B use the same socket ('s2') to talk to A using read(2) or > >recv(2), or does A have to accept(2) traffic from B using a different > >socket? > > > > The programming language I'm using is C (not C++). -- Yar