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

re: RDP request



This is a response to a bboard request from a couple of months ago.


    ;;; -*- Mode: LISP; Syntax: Common-lisp; Package: USER; Base: 10 -*-

    ;;; The folloing is an example of using datagrams on the Symbolics. It
    ;;; does nothing usefull, but it works.
    ;;;
    ;;; Disclaimer - The following example was derived by trial and error.
    ;;; There are possibly better ways to solve the problem, but I could not
    ;;; find them documented anywhere (I did an exhaustive, 15 minute
    ;;; search)!

    ;;; D,#TD1PsT[Begin using 006 escapes](1 0 (NIL 0) (NIL :BOLD NIL) "CPTFONTCB")Step 1)(2 0 (NIL 0) (NIL NIL NIL) "CPTFONT")  1Define server (will handle server-side operations)
    2;;;
    (net:define-server (3 0 (NIL 0) (NIL :ITALIC NIL) "CPTFONTI"):protocol-name
    2    (:medium :datagram
	 :error-disposition :debugger
	 :who-line t
	 :request-array (msg-array start end))
       (3server-function 2msg-array start end))

    ;;; 1Step 2)  Define protocol (client side operations)
    2;;;
    (net:define-protocol 3:protocol-name
    2		     (3:service-name 2:datagram)
      (:invoke (service-access-path)
	(3client-function 2service-access-path)))

    ;;; 1Step 3)  Link protocol to specific port
    2;;;
    ;;; Note - Symbolics will not allow UDP ports >= 1024.  If you want to
    ;;; talk to a UNIX system (which only allows port #s >= 1204) you will
    ;;; have to edit two methods: (:receive-ip-packet udp-protocol) and
    ;;; (:gensym-udp-port udp-protocol) in >rel-7>ip-tcp>udp.lisp to allow
    ;;; the higher port number. (I'm sure these changes are not sanctioned
    ;;; by Symbolics, so proceed at your own risk).  Also, the Symbolics has
    ;;; a hard limit on UDP packet size. I believe it is 1468 bytes of data
    ;;; (the header fills the rest).  This fact is not documented anywhere I
    ;;; could find and caused me a lot of heartache.

    (defconstant SERVICE-PORT 1000)

    (tcp:add-udp-port-for-protocol 3:protocol-name 2SERVICE-PORT)

    (tcp::patch-udp-port SERVICE-PORT)

    ;;; 1step 4)  Add service to namespace using namespace editor
    2;;;
    ;;; Service: (4 0 (NIL 0) (NIL :BOLD-ITALIC NIL) "CPTFONTBI")Set: 3service-name 2UDP3 protocol-name

    2

    (defvar *buffer-stack* nil)

    (defun server-function (array start end)
      (let ((buffer (make-array (- end start))))
	(copy-array-portion array start end buffer 0 (- end start))
	(push buffer *buffer-stack*)
	(values t 0)))

    

    (defun client-function (service-access-path)
      (let* ((args (neti:service-access-path-args service-access-path))
	     (message (car args))
	     (conn (net:get-connection-for-service
		     service-access-path
		     :rfc-text message
		     :future-p t)))
	(when conn
	  (send conn :close :abort))
	message))

    

    (net:define-protocol 3:protocol-name
    2		     (3:service-name2 :local)
      (:invoke (service-access-path)
	(3local-client-function 2service-access-path)))

    (defun local-client-function (service-access-path)
      (let* ((array (car (neti:service-access-path-args service-access-path)))
	     (start 0)
	     (end (length array)))
	(server-function array start end)))