comp.lang.ada
 help / color / mirror / Atom feed
From: "Andrew Carroll" <andrew@carroll-tech.net>
To: <comp.lang.ada@ada.eu.org>
Subject: copy constructor for sockets
Date: Mon, 24 May 2004 05:28:42 -0600
Date: 2004-05-24T05:28:42-06:00	[thread overview]
Message-ID: <mailman.15.1085397053.401.comp.lang.ada@ada-france.org> (raw)

Wow, GREAT information!!  Thanks all!!

Steve, Matthew, Marius:
Accept() does block, as you expected.  At least with AdaSockets.

I have three tasks.  One is the "accepting" task and the other two tasks
just do various work depending on the "method" of an HTTP header
(obtained from the first Get_Line(<socket>)).  So, accept() initializes
the socket, does one Get_Line(<socket>) and then if the method is GET,
then I want to pass the socket to task 'A'.  If the method is POST then
I want to pass the socket to task 'B'.  In both cases, I want the task
to provide the HTTP user with a response and close the socket.

All the "accepting" task does is initialize sockets and create new
tasks.  Well, it will do other things but right now I am just
experimenting.  Your select() or poll() idea is beautiful!  Because
then, when an accept would occur, I can have the tasks ('A' or 'B')
handle the whole "session".  Question now is, how do I know which task
to assign it to for handling?  I cannot get into the HTTP header before
I "accept".  Hmmmm....Anyway...

I once downloaded AWS but never really read about it because I was
looking into the source code for other things about an idea I had, of
which I gave up on.  I went back to read about AWS recently and it
provides the Callbacks and Method ?API? which would accomplish what I am
trying to achieve.  I haven't investigated "how" they did it and in fact
I would rather drudge through this for learning purposes, at least for a
while.

So, in the end I think I will ask permission to use AWS and skip the
"accepting" task in my design.  Then place the task 'A' and task 'B'
implementations in the Callback based on Method from AWS.  (forgive me,
I do not have the AWS documentation open to give accurate API names)

Never the less I am learning some great things.  You mentioned that a
socket is a file descriptor (Unix) and I'm not quite sure I fully
understand the implications of that.  I "heard" that sockets were
designed in such a way that it would be "transparent", like working with
files.  Does that mean I can do a seek() on a socket?  When people throw
out the term "file descriptor" and start talking about "small positive
integers" I draw a blank as to how those are used for "communication"
over a network device in general.  After all, there are MANY small
positive integers on my computer.  I'm assuming the file descriptor (fd)
means something to the OS?  So somewhere in the kernel or "shell"
interrupt handler there is an else if (//it is a small positive integer)
{ //must be a socket, fire-up the RS-232 driver}?

I thought a socket was an abstraction from an address?  For example. the
address to a UART or RS-232 PIC.  A driver of which is written (probably
a module) to control that device.  So how does a fd relate to that
driver?  Or are you saying that somewhere in my /dev directory there is
a directory entry for my UART?  I can just arbitrarily (at risk of
destruction) send data to the UART through an entry in the /dev
directory?

I guess I'm just trying to fill in the holes of what I have learned thus
far.  Or maybe more appropriately what I have failed to learn.

Thanks again!!

Andrew Carroll
Carroll-Tech
720-273-6814
andrew@carroll-tech.net




             reply	other threads:[~2004-05-24 11:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-24 11:28 Andrew Carroll [this message]
2004-05-25  5:29 ` copy constructor for sockets Simon Wright
  -- 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-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