[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

u_short to int conversion

Cc: nrouquet@pollux, gasser@pollux

[Allegro CL, 3.0.3 on a Sequent Symmetry running Dynix V3.0.12]

I have problems to pass a port number from C to lisp.

int GetSockPort(Sock)
     int Sock;
  struct sockaddr_in sockad;
  int len;

  getsockname(Sock,(struct sockaddr *)&sockad,(int *)&len);


(defforeign 'get-sock-port
  :entry-point (convert-to-lang "GetSockPort" :language :c)
  :return-type :integer
  :arguments '(fixnum))

Well, when get-sock-port is called with a socket, the value returned
is correct. Many times I have had the same value for two different sockets.
I think the problem lies in the fact that the sin_port of the sockaddr
structure is declared as a u_short.

What is the correct way to declare the foreign function and/or
to define the C function?

Since I'm at it, I have a remark on the documentation of Allegro CL.
I hope that there will be a more detailed description of the Allegro CL
implementation specifics. As far as I am concerned, I have used the foreign
function interface, the multiprocessing extensions, the error functions
and all of these suffer of a common documentation problem:

Several examples are discussed to illustrate what are the facilities available
but when a really specific case is at stake, there is always a couple of details
not described. This means that I've had to browse several times the doc to see
if any example would describe a solution to my problems. I strongly encourage
you to document what is available on a function basis rather than an example basis.
As a comparative experience, I can find my way to my problems much easier with
Lucid's documentation (V3.x) rather than with Allegro's.

Nicolas Rouquette			E-mail: nrouquet%pollux.usc.edu@usc.edu
Distributed AI Group    		Phone:  (213) 743-3472
Computer Science Department MC-0782
University of Southern California
Los Angeles, CA 90089-0782