comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Lorenzen <mark.lorenzen@ofir.dk>
Subject: Re: copy constructor for sockets
Date: Sun, 23 May 2004 11:43:11 +0200
Date: 2004-05-23T11:43:11+02:00	[thread overview]
Message-ID: <m365anlbrk.fsf@niflheim.malonet> (raw)
In-Reply-To: mailman.9.1085259629.401.comp.lang.ada@ada-france.org

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



  parent reply	other threads:[~2004-05-23  9:43 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 [this message]
2004-05-23 11:27 ` Simon Wright
  -- 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