Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
sockets in lisp
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jorge Tavares  
View profile  
 More options Nov 3 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Jorge Tavares <j...@student.dei.uc.pt>
Date: 1999/11/03
Subject: sockets in lisp

        Hello all,

        I wanted to try to make a simple client server aplication with
        TCP sockets but I was unable to find information on the subject.
        The books I have don't talk about it and I have tried to find some
        web pages but didn't get anything. I've also tried to look in
        deja news but the serach results didn't give me a clear picture
        of the subject. I was able to realise that there must be something
        like open-tcp-stream and then work like a normal stream but I
        think there is more to the subject. If somebody would be kind
        enough to point me in some direction I would be apreciate.

        Thanks !
        Jorge

-= Jorge Tavares =-
-= j...@student.dei.uc.pt =- -= 0936 6669824 =-
-= CT2HFF=- -= http://student.dei.uc.pt/~jast =-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Nov 3 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/11/03
Subject: Re: sockets in lisp
* Jorge Tavares
| I wanted to try to make a simple client server application with TCP
| sockets but I was unable to find information on the subject.

  if you're working with Allegro CL 5.0.1 Lite for Windows, you may want to
  visit www.franz.com and look at their support documentation.  according
  to these files, it includes the Allegro CL socket library.  I'm not sure
  the 5.0 Lite edition did.  if it didn't, grab the new version.  (if you
  use the Personal or Student edition of Allegro CL, these do not contain
  the socket library.)

| The books I have don't talk about it and I have tried to find some web
| pages but didn't get anything.

  there should be documentation coming with your CD or download that
  explains this in detail.  look for doc/cl/socket.htm in your Allegro CL
  installation directory.  it contains all you need to know, including
  descriptions of all the functions involved and links to their pages.

#:Erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pierre R. Mai  
View profile  
 More options Nov 3 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: p...@acm.org (Pierre R. Mai)
Date: 1999/11/03
Subject: Re: sockets in lisp

Jorge Tavares <j...@student.dei.uc.pt> writes:
>    Hello all,

>    I wanted to try to make a simple client server aplication with
>    TCP sockets but I was unable to find information on the subject.
>    The books I have don't talk about it and I have tried to find some
>    web pages but didn't get anything. I've also tried to look in
>    deja news but the serach results didn't give me a clear picture
>    of the subject. I was able to realise that there must be something
>    like open-tcp-stream and then work like a normal stream but I
>    think there is more to the subject. If somebody would be kind
>    enough to point me in some direction I would be apreciate.

>    Thanks !
>    Jorge

Access to sockets is not part of the ANSI CL standard, so the details
of this will vary between implementations, although the general
principle (that you describe above) will be similar.  Erik has already
posted hints for ACL, here are some more for other systems:

a) Get cl-http, which would include implementation specific code for
   listening and opening on sockets for nearly all implementations
   (see http://www.ai.mit.edu/projects/iiip/doc/cl-http/home-page.html)

b) For CMUCL, this is the skeleton of code that is needed to listen on
   a socket and spawn functions that handle connections (this uses
   multi-processing, so will only work in this way on iA32):

(defun ip-address-string (address)
  (format nil "~D.~D.~D.~D"
          (ldb (byte 8 24) address)
          (ldb (byte 8 16) address)
          (ldb (byte 8 8)  address)
          (ldb (byte 8 0)  address)))

(defun http-listener (port server)
  (let ((fd (ext:create-inet-listener port)))
    (unless fd (error "Cannot bind port ~D." port))
    (unwind-protect
         (progn
           (setf (process-name *current-process*)
                 (format nil
                         "HTTP connection listener on port ~D with server ~A"
                         port server))
           (format t "~&;;; Started lisp connection listener on ~
                port ~d for server ~A~%" port server)
           (loop
               ;; Wait for new connection
               (process-wait-until-fd-usable fd :input)
               #+CLASH-DEBUG
               (format t "~&;;; At ~D Got Connection...~%"
                       (get-internal-real-time))
               (multiple-value-bind (new-fd remote-host)
                   (ext:accept-tcp-connection fd)
                 #+CLASH-DEBUG
                 (format t "~&;;; At ~D Have Connection...~%"
                         (get-internal-real-time))
                 (let* ((host-entry (ext:lookup-host-entry remote-host))
                        (stream (sys:make-fd-stream new-fd :input t :output t))
                        (connection (make-instance 'simple-connection
                                                   :stream stream)))
                   #+CLASH-DEBUG
                   (format t "~&;;; At ~D Established Connection...~%"
                           (get-internal-real-time))
                   (make-process
                    #'(lambda ()
                        (serve-connection server connection))
                    :name (format nil "HTTP connection from ~A"
                                  (if host-entry
                                      (ext:host-entry-name host-entry)
                                      (ip-address-string remote-host))))))))
      (when fd (unix:unix-close fd)))))

(defun start-http-listener (port server)
  (make-process #'(lambda () (http-listener port server))))

(defun initialize-clash (&optional (idle-process mp::*initial-process*))
  (setf mp::*idle-process* idle-process))

Regs, Pierre.

--
Pierre Mai <p...@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marc Cavazza  
View profile  
 More options Nov 3 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marc Cavazza <M.Cava...@bradford.ac.uk>
Date: 1999/11/03
Subject: Re: sockets in lisp

Jorge Tavares wrote:
>         Hello all,

>         I wanted to try to make a simple client server aplication with
>         TCP sockets but I was unable to find information on the subject.
>         The books I have don't talk about it and I have tried to find some
>         web pages but didn't get anything. I've also tried to look in
>         deja news but the serach results didn't give me a clear picture
>         of the subject. I was able to realise that there must be something
>         like open-tcp-stream and then work like a normal stream but I
>         think there is more to the subject. If somebody would be kind
>         enough to point me in some direction I would be apreciate.

Hi,

As Erik said, you should find good examples on Franz's site. You can also
choose to write your client-server application from the basic examples given
in the Allegro documentation on sockets. You'll find below very simple code
excerpts
adapted from their examples (that I used for Lisp/C++ communication):

For a server, you have to create a stream from the socket before using it:

(let ((so (socket:make-socket
      :connect :passive
      :remote-host "123.89.76.54"
      :local-host "foobar"                          ;; don't need both :-)
      :format :text
      :local-port port)))
    ...
        (let ((str-a (gensym)))
           (setq str-a (socket:accept-connection so :wait wait))
   ...
   and then use str-a as a normal stream for I/O

And on the client side you'd have something like:

...
(socket:with-pending-connect
       (mp:with-timeout (timeout (error "Connection failed"))  ;; timeout as
&optional parameter
         (let ((s (socket:make-socket
                      :connect :active
                      :remote-host "123.45.67.89"
                      :remote-port rport)))
;; rport is the port you connect to (was a fn parameter)
...
you can directly use "s" as a stream for I/O in this case

Of course, you close sockets with the "close" function: do not
forget to wrap it with an "unwind-protect". Use of unwind-protect
appears in the more extensive examples on Franz's site

(Clemens Heitzinger also posted a socket example a few days ago, using
Macintosh Common Lisp with "open-tcp-stream")

Hope this helps

Marc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Tavares  
View profile  
 More options Nov 3 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Jorge Tavares <j...@student.dei.uc.pt>
Date: 1999/11/03
Subject: Re: sockets in lisp

        Hello !

        I want to thank you all for your support. You gave me plenty of
material to look for and study, it was more than I thought up. Once again,
thanks !

        Jorge

-= Jorge Tavares =-
-= j...@student.dei.uc.pt =- -= 0936 6669824 =-
-= CT2HFF=- -= http://student.dei.uc.pt/~jast =-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »