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,FREEMAIL_FROM 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!newsfeed1.uni2.dk!news.get2net.dk.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: copy constructor for sockets References: From: Mark Lorenzen Message-ID: User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:2v9b0Ls8dqg4LnuISb3yN7J/ENQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 23 May 2004 11:43:11 +0200 NNTP-Posting-Host: 82.180.17.211 X-Complaints-To: abuse@colt-telecom.dk X-Trace: news.get2net.dk 1085305375 82.180.17.211 (Sun, 23 May 2004 11:42:55 CEST) NNTP-Posting-Date: Sun, 23 May 2004 11:42:55 CEST Organization: Colt Telecom Kunde Xref: controlnews3.google.com comp.lang.ada:787 Date: 2004-05-23T11:43:11+02:00 List-Id: "Andrew Carroll" writes: > Okay, > > I have written a small test server. All it does is Accept() connections > and Get_line() and then a final Get(). It is just an experiment but I > want the server now to create a task (with a socket as one of it's > members) and initialize that socket. There are two types of tasks > however and the distinction between which task to create comes from the > header information in the get_line() right after the Accept(). If it is > a GET header then I would create task type A, if it is a POST then I > would create task type B. > > 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. > > The other option is to use an access yet I think it could be done > without it. > > Doesn't the ":=" operator to a "deep copy"? > > Andrew This design is enough if you have a small number of connections. If you want to design a high performance server application with thousands of connections, you must reduce the use of tasks as the system will drown in conext switches otherwise. Some links with good info: http://pl.atyp.us/content/tech/servers.html http://www.kegel.com/c10k.html But remember, if you are only learning to design a server application, then you should not bother about performance with thousands of connections yet. It is better to learn UNIX socket communication first. - Mark Lorenzen