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!newsrout1.ntli.net!news-in.ntli.net!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: 23 May 2004 12:27:38 +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 1085311934 9686 62.49.19.209 (23 May 2004 11:32:14 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 23 May 2004 11:32:14 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: controlnews3.google.com comp.lang.ada:789 Date: 2004-05-23T12:27:38+01:00 List-Id: "Andrew Carroll" 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.