gcl-devel
[Top][All Lists]
Advanced

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

RE: [Gcl-devel] opening a socket to a web server


From: Mike Thomas
Subject: RE: [Gcl-devel] opening a socket to a web server
Date: Wed, 25 Feb 2004 17:50:41 +1000

Hi Michael.

Others may have something more specific to say as I'm not well versed on GCL
sockets (or sockets in general) but here is the documentation from the C
source.

DEFUN_NEW("OPEN-NAMED-SOCKET",object,fSopen_named_socket,SI,1,1,NONE,OI,OO,O
O,OO,(fixnum port),
"Open a socket on PORT and return (cons fd portname) where file \
descriptor is a small fixnum which is the write file descriptor for \
the socket.  If PORT is zero do automatic allocation of port")


DEFUN_NEW("ACCEPT-SOCKET-CONNECTION",object,fSaccept_socket_connection,
          SI,1,1,NONE,OO,OO,OO,OO,(object named_socket),
      "Given a NAMED_SOCKET it waits for a connection on this \
and returns (list* named_socket fd name1) when one is established")

I have no idea how well these functions work on Windows but my suspicion is
not very well if at all.  SI::SOCKET works to the extent that Maxima uses it
(see the example code below).

Camm - notice that the doc strings of these DEFUN_NEW functions are not
ending up in a place accessible to the CL "describe" function - a bug which
I think we should try and fix to avoid wastage of useful information.

Cheers

Mike Thomas.

>From the Maxima source code here is an example of how to use SI::SOCKET:

;; very simple server started on port

(and (find-package "MAXIMA") (push :maxima *features*))

#+maxima
(in-package "MAXIMA")



(defun user::setup ( port &optional (host "localhost"))
  (let* ((sock (open-socket host port)))
    (setq me sock)
   #+gcl (setq si::*sigpipe-action* 'si::bye)
    (setq *socket-connection* sock)
    (setq *standard-input* sock)
    (setq *standard-output* sock)
    (setq *error-output* sock)
    (setq *terminal-io* sock)
    (format t "pid=~a~%"        (getpid))
    (force-output sock)
    (setq *debug-io* sock)
    (values)
    ))

;;; from CLOCC: <http://clocc.sourceforge.net>
(defun open-socket (host port &optional bin)
  "Open a socket connection to HOST at PORT."
  (declare (type (or integer string) host) (fixnum port) (type boolean bin))
  (let ((host (etypecase host
                (string host)
                (integer (hostent-name (resolve-host-ipaddr host))))))
    #+allegro (socket:make-socket :remote-host host :remote-port port
                                  :format (if bin :binary :text))
    #+clisp (socket-connect port host :element-type
                                 (if bin '(unsigned-byte 8) 'character))

    #+cmu (sys:make-fd-stream (ext:connect-to-inet-socket host port)
                              :input t :output t :element-type
                              (if bin '(unsigned-byte 8) 'character))
    #+gcl (si::socket port :host host)
    #+lispworks (comm:open-tcp-stream host port :direction :io :element-type
                                      (if bin 'unsigned-byte 'base-char))
    #-(or allegro clisp cmu gcl lispworks)
    (error 'not-implemented :proc (list 'open-socket host port bin))))



#+maxima
(progn
(setq $in_netmath t)
(setq $show_openplot nil))

#+clisp
(defun getpid ( &aux tem)

  (cond ((fboundp 'sys::program-id)
         (sys::program-id))
                                        ; ;under windows above does not work.
        ((consp (setq tem (errset (system::getenv "PID"))))
         (read-from-string (car tem)))
        (t (format t "using fake value for pid") -1))
  )
#+cmu
(defun getpid () (unix:unix-getpid))

#+(or gcl clisp cmu)
(defun xchdir (w)
  #+clisp (cd w)
  #+gcl (si::chdir w)
  #+cmu (unix::unix-chdir w)
  )





| -----Original Message-----
| From: address@hidden
| [mailto:address@hidden
| Behalf Of michael philetus weller
| Sent: Wednesday, 25 February 2004 1:08 PM
| To: address@hidden
| Subject: [Gcl-devel] opening a socket to a web server
|
|
| hi,
|
| I am running gcl 2.5.0 in gnu emacs on windows xp and am trying to build a
| web crawler for a class assignment at the university of washington. I
| downloaded this windows binary from
|
|   http://www.cs.utexas.edu/users/novak/gclwin.html
|
| When I type
|
|   (apropos 'socket)
|
| I get
|
|   SYSTEM:ACCEPT-SOCKET-CONNECTION  Function
|   SYSTEM:SOCKET  Function
|   SYSTEM:OPEN-NAMED-SOCKET  Function
|   SOCKET
|
| but I can't find any documentation on any of these functions in the
| documentation folder.
|
| I noticed in the news item on the 2.5.1 release that sockets are listed
| under the features.
|
| could you point me towards some documentation or code samples that could
| help?
|
| thanks,
|
| mike weller
| address@hidden
|
|
| _______________________________________________
| Gcl-devel mailing list
| address@hidden
| http://mail.gnu.org/mailman/listinfo/gcl-devel
|
|






reply via email to

[Prev in Thread] Current Thread [Next in Thread]