comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: copy constructor for sockets
Date: 22 May 2004 12:55:07 +0100
Date: 2004-05-22T12:55:07+01:00	[thread overview]
Message-ID: <x7v3c5svfqc.fsf@smaug.pushface.org> (raw)
In-Reply-To: mailman.6.1085220387.401.comp.lang.ada@ada-france.org

"Andrew Carroll" <andrew@carroll-tech.net> 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.



  reply	other threads:[~2004-05-22 11:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-22 10:19 copy constructor for sockets Andrew Carroll
2004-05-22 11:55 ` Simon Wright [this message]
2004-05-22 18:39   ` tmoran
2004-05-23 21:04   ` Matthew Heaney
2004-05-24  7:13     ` Marius Amado Alves
2004-05-24  3:23       ` Matthew Heaney
2004-05-24  4:53         ` Simon Wright
2004-05-24  5:20           ` tmoran
2004-05-25  4:53             ` Simon Wright
2004-05-24 12:36           ` Matthew Heaney
2004-05-25 21:50           ` Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
2004-05-22 21:18 Andrew Carroll
2004-05-22 21:46 ` tmoran
2004-05-23 11:21   ` Simon Wright
2004-05-24 18:26     ` tmoran
2004-05-25  5:10       ` Simon Wright
2004-05-25  6:37         ` tmoran
2004-05-23  9:43 ` Mark Lorenzen
2004-05-23 11:27 ` Simon Wright
2004-05-24 11:28 Andrew Carroll
2004-05-25  5:29 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox