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

"Andrew Carroll" <andrew@carroll-tech.net> writes:

> So, the server must accept the socket and do an initial read to get the
> header information (GET or POST) to know which type of task to create.
> Then I want to initialize the socket that is in the task type to be the
> same as the socket in the server that was just accepted.  It would
> probably need to be a "deep copy" of the socket because the server will
> need to release the socket and the task will need to keep the socket.
> By release I mean close() and by keep I mean use for communication.

You mustn't finally close() the socket you get back from the accept()
until you have sent your reply. The browser client is expecting you to
use it.

In C terms, you could dup() the socket, pass the result off to the
task, and close() the first socket, but it doesn't seem necessary here
-- might be a good idea when the thing that is going to talk over the
socket is a child process that you have fork()ed, so as to avoid a
file handle leak in the server process, but these are tasks so I don't
think that's likely to be a problem. Others will know more than I do
about this!

-- 
Simon Wright                               100% Ada, no bugs.



  parent reply	other threads:[~2004-05-23 11:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-22 21:18 copy constructor for sockets 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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-05-24 11:28 Andrew Carroll
2004-05-25  5:29 ` Simon Wright
2004-05-22 10:19 Andrew Carroll
2004-05-22 11:55 ` Simon Wright
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
replies disabled

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