From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d0728b52f51f685e X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: copy constructor for sockets Date: 22 May 2004 12:55:07 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1085227184 27152 62.49.19.209 (22 May 2004 11:59:44 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 22 May 2004 11:59:44 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: controlnews3.google.com comp.lang.ada:772 Date: 2004-05-22T12:55:07+01:00 List-Id: "Andrew Carroll" writes: > I am wondering if it is possible to write a copy constructor for a > socket. > I did not see one in AdaSockets however I have never written a "copy > constructor" in Ada so I probably wouldn't know what to look for. > > Maybe it violates some standard for socket communication to have a > copy constructor for a socket? You have to decide what you want your copy to do! If you just want to pass the socket around, a plain copy will do fine. But of course you need to decide what the semantics are. Copying where one copy is used for read & the other for write is fine, sockets are like that. But if you have copies where each is used for reading or writing you have application-level protocol problems you have to decide: * is it the same write socket? (ie, the guy at the other end is still there and you have two writers): then you'd better be sure your sockets are thread-safe (VxWorks stock ones aren't, to my surprise, so a single large send(2) can get split). Or you could ensure exclusive access with a mutex of some sort. * is it the same read socket? (ie, only one guy at the other end, you are supplying multiple read tasks): better be sure you can split the input stream at logical record boundaries. * do you want a new stream to a new remote process? then it's all got _much_ more complicated. And it'll be a matter of application policy, far too specific to delegate to a low-level socket abstraction; you'd need to make your own higher-level abstraction. -- Simon Wright 100% Ada, no bugs.