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!news.tele.dk!news.tele.dk!small.news.tele.dk!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: 23 May 2004 12:21:32 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <_SPrc.95520$536.16845336@attbi_s03> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1085311569 9686 62.49.19.209 (23 May 2004 11:26:09 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 23 May 2004 11:26:09 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: controlnews3.google.com comp.lang.ada:788 Date: 2004-05-23T12:21:32+01:00 List-Id: tmoran@acm.org writes: > Remember that a task is a thread of control, not a sequence of > instructions. From that viewpoint, your server needs to fire up a > task/thread, and that thread needs to find out whether it should execute > the Get or the Put sequence of instructions. You can pass the server > socket to the task during the rendezvous, and let the task create a socket > and do the socket-accept. Is it really possible to have multiple accept()s? You live and learn! (I thought you could only have one accept(), which blocks until a client connect()s and then returns a new socket ... so, with your design, what is the server doing while the task calls accept()? I know you can use select() or poll() to block until an accept() would succeed, is that the idea? > That lets the server get back to waiting for > calls as quickly as possible, while the task does the Get_Line (which > could potentially take a while) and calls an appropriate Handle_Get or > Handle_Post procedure. You can see an example of this in Smplsrvr (part > of the free Claw download at www.rrsoftware.com). You might also want to > see how AWS does it. > > > Doesn't the ":=" operator to a "deep copy"? > If the object is Limited, ":=" is illegal. (That's the case for Claw > Sockets.) If it's Controlled, then ":=" does a bit pattern copy followed > by a call on Adjust, which may do nothing, may modify pointers or > whatever, or may do a deep copy - whatever it wants. If the object is not > Controlled, and isn't Limited, then ":=" just does a bitwise copy. That applies recursively to components, of course (remembering that a type with limited components has to be limited, of course). I don't know AdaSockets, but GNAT.Sockets (3.15p) has type Socket_Type is private; which means that assignment is available, and, in the private part, type Socket_Type is new Integer; and in the body (eg) procedure Accept_Socket (Server : Socket_Type; Socket : out Socket_Type; Address : out Sock_Addr_Type) is Res : C.int; Sin : aliased Sockaddr_In; Len : aliased C.int := Sin'Size / 8; begin Res := C_Accept (C.int (Server), Sin'Address, Len'Access); if Res = Failure then Raise_Socket_Error (Socket_Errno); end if; Socket := Socket_Type (Res); Address.Addr := To_Inet_Addr (Sin.Sin_Addr); Address.Port := Port_Type (Network_To_Port (Sin.Sin_Port)); end Accept_Socket; so you can see that it's extremely close to the C accept(2); the socket is essentially a file descriptor, in Unix terms anyway. So assignment works (for this binding) as it would in C. -- Simon Wright 100% Ada, no bugs.