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!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.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: 25 May 2004 06:29:56 +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 1085463273 3052 62.49.19.209 (25 May 2004 05:34:33 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 25 May 2004 05:34:33 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: controlnews3.google.com comp.lang.ada:811 Date: 2004-05-25T06:29:56+01:00 List-Id: "Andrew Carroll" writes: > 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 think that's a big Hmmmm :-( The task is a thread of control, whereas you want different behaviour. When I was designing my Embedded Web Server (http://sourceforge.net/projects/embed-web-srvr/) I managed that by having the Response be a tagged type, created by factory operations registered against the .. damn, forgotten the name, the "/projects/embed-web-srvr/" in the URL above. > 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}? It's going to be some higher level of abstraction in the OS than that, after all you might be using an Ethernet LAN or a cable modem. But, yes-ish. > 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? _Very_ roughly, on Unix (POSIX) systems, the fd looks to you, the user, as a small positive integer, but inside the OS it's an index into a whole set of data structures. These might hold pointers to the actual operations to perform read(), write(), sendTo() etc + pointers to the actual connected channel (console i/o for fd 0, some networking stack for your server). But you're right, it is an abstraction; this small positive integer is not something you want to go adding 1 to! -- Simon Wright 100% Ada, no bugs.