From: George H. John
Subject: Allegro IPC / C interface question
Date: 
Message-ID: <1992Aug10.221756.13557@kronos.arc.nasa.gov>
A "typical" line of allegro code to open an internet 
connection might look something like this:


(connect sock server 16)

Where "connect" is an entry to the standard c library function
connect. 

Problem: connect returns 0 if successful and -1 if unsuccessful.
In c code, it also sets the variable errno to some value to
tell you what went wrong.

How do you get the value "errno" in lisp?

While I'm at it, the ipc code distributed with allegro 4.1 
contains a call to mp:mpwaitfor -- I can't find any documentation
for the function.  Any pointers?

Thanks,
George

From: David Loewenstern
Subject: Re: Allegro IPC / C interface question
Date: 
Message-ID: <DAVEL.92Aug11173231@homxc.ATT.COM>
... On 10 Aug 92 22:17:56 GMT, ·····@kronos.arc.nasa.gov (George H. John) said:

[...]
} How do you get the value "errno" in lisp?
[...]

I wound up having to create a C function like this:

int ailr_errnumber ()
{
  extern errno;
  return errno;
}
and, of course, using the foreign language interface to call the function.

You may also want to look up the C perrno() function.

These opinions are shareware.  If you like the product,
please send your $0.02 to
               David Loewenstern
   ·····@homxc.att.com or simply ·············@att.com
From: Steve Haflich
Subject: Re: Allegro IPC / C interface question
Date: 
Message-ID: <1992Aug12.003552.4859@franz.com>
In article <······················@kronos.arc.nasa.gov> ·····@kronos.arc.nasa.gov (George H. John) writes:
>
>A "typical" line of allegro code to open an internet 
>connection might look something like this:
>
>(connect sock server 16)
>
>Where "connect" is an entry to the standard c library function
>connect. 

Actually, unless you have specific needs to manipulate sockets
directly, you should consider using the higher-level interfaces
provided by file ipc.  The IPC:OPEN-NETWORK-STREAM does all the work
of connecting as client to a Unix- or Internet-domain socket and
returning a bidirectional lisp stream to the socket.  (See the sample
implementation of finger at the end of the file.)  Of course, if you
need to do socket manipulations more complicated socket manipulations
than reading and writing a character stream, you'll have to do some
lower-level socket programming.

>Problem: connect returns 0 if successful and -1 if unsuccessful.
>In c code, it also sets the variable errno to some value to
>tell you what went wrong.
>
>How do you get the value "errno" in lisp?

The following will suffice to access the value of _errno directly from
Lisp:

   user(1): (ff:def-c-type (long-int :in-foreign-space) :long)
   long-int
   user(2): (setq *errno-address* (ff:get-entry-point "_errno"))
   276872
   user(3): (open "nowhere")
   Error: File "/net/flash/usr/tech/smh/cl/src/nowhere" does not exist.
     [condition type: file-error]
   [1] user(4): (long-int *errno-address*)
   2		;; ENOENT, the expected errno.

>While I'm at it, the ipc code distributed with allegro 4.1 
>contains a call to mp:mpwaitfor -- I can't find any documentation
>for the function.  Any pointers?

You probably mean MP::MPWATCHFOR, which is undocumented and purposely
_not_ exported.  Public access to this functionality is provided by
the exported function MP:WAIT-FOR-INPUT-AVAILABLE documented in the
Allegro User Guide.  It is only historical happenstance that ipc
doesn't use it.
From: Larry Stead
Subject: Re: Allegro IPC / C interface question
Date: 
Message-ID: <LSTEAD.92Aug13113321@iris.bellcore.com>
--