[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Talking Sun Lucid<->Symbolics: answer + some code
Apparently the way to go is with RPC (especially since I already had RPC code
on the Sym side, so I just had to read the Sun documentation on their RPC).
Thanks to Eyvind Ness, David Duff, Vincent Hwang, and Richard Shapiro for
helpful pointers.
For those others interested, I'll include a bit o' code below. (It's not the
best stuff in the world, but you get what you pay for.) What I have is C code
for a Sun-side client talking to a Sym-side lisp server: You can do something
like 'ear-client <hostname> "(this is a list)"' and it should show up on the
Symbolics side. Going the other way isn't too difficult. And to put it into
Lucid, just import the C code.
Hope something here's useful. Thanks again to the respondants. --Hans
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: ear-client.c ear.h rpcgen.x sym-serv.lisp Makefile
# Wrapped by tallis@drake on Sat Nov 16 20:10:16 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ear-client.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ear-client.c'\"
else
echo shar: Extracting \"'ear-client.c'\" \(949 characters\)
sed "s/^X//" >'ear-client.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <rpc/rpc.h>
X#include "rpcgen.h"
X#include "ear.h"
X
XCLIENT *cl;
X
Xmain (argc,argv)
Xint argc;
Xchar *argv[];
X{
X int *result;
X char *server;
X char *message;
X
X if (argc != 3) {
X fprintf(stderr, "%s given wrong number of arguments.\n", argv[0]);
X exit(1); }
X
X server = argv[1];
X message = argv[2];
X
X cl = clnt_create(server, EAR_PROGRAM, EAR_VERSNUM, EAR_PROTOCOL);
X if (cl == NULL) {
X fprintf(stderr, "clnt_create failed\n");
X clnt_pcreateerror(server);
X exit(1); }
X
X /* Call the remote procedure */
X result = give_ap_planning_problem_proc_1(&message, cl); /* 1 = version */
X if (result == NULL) {
X fprintf(stderr, "call to give-ap-planning-prob failed\n");
X clnt_perror(cl, server);
X exit(1); }
X
X if (*result == EAR_MISC_ERROR) {
X fprintf(stderr, "ear-client: %s couldn't handle the call. \n",
X server);
X exit(1); }
X
X fprintf(stdout, "Successful call to %s.\n", server);
X exit(0);
X}
END_OF_FILE
if test 949 -ne `wc -c <'ear-client.c'`; then
echo shar: \"'ear-client.c'\" unpacked with wrong size!
fi
# end of 'ear-client.c'
fi
if test -f 'ear.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ear.h'\"
else
echo shar: Extracting \"'ear.h'\" \(96 characters\)
sed "s/^X//" >'ear.h' <<'END_OF_FILE'
X#define EAR_PROTOCOL "tcp"
X
X/* error returns */
X#define EAR_NO_ERROR 0
X#define EAR_MISC_ERROR 1
END_OF_FILE
if test 96 -ne `wc -c <'ear.h'`; then
echo shar: \"'ear.h'\" unpacked with wrong size!
fi
# end of 'ear.h'
fi
if test -f 'rpcgen.x' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'rpcgen.x'\"
else
echo shar: Extracting \"'rpcgen.x'\" \(310 characters\)
sed "s/^X//" >'rpcgen.x' <<'END_OF_FILE'
X/* This will be converted into rpcgen.h by Sun's rpcgen(1). */
X
Xprogram EAR_PROGRAM {
X version EAR_VERSNUM {
X /* one line for each rpc procedure we define */
X int GIVE_AP_PLANNING_PROBLEM_PROC(string) = 1; /* procnum */
X } = 1; /* version */
X} = 0x7F008005; /* program must match entry on Slimer */
END_OF_FILE
if test 310 -ne `wc -c <'rpcgen.x'`; then
echo shar: \"'rpcgen.x'\" unpacked with wrong size!
fi
# end of 'rpcgen.x'
fi
if test -f 'sym-serv.lisp' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sym-serv.lisp'\"
else
echo shar: Extracting \"'sym-serv.lisp'\" \(1939 characters\)
sed "s/^X//" >'sym-serv.lisp' <<'END_OF_FILE'
X;;; -*- Mode: LISP; Syntax: Lisp+C; Package: RAGE; Base: 10 -*-
X
X;;;----------------------------------------------------------------
X;;; procedure numbers; must match those on sun side
X;;;----------------------------------------------------------------
X(defparameter give-ap-planning-problem-proc 1) ; unused
X(defparameter EAR-NO-ERROR 0)
X(defparameter EAR-MISC-ERROR 0)
X
X(RPC:DEFINE-REMOTE-MODULE EAR-Server
X (:NUMBER #x7F008005)
X (:VERSION 1)
X (:client :c)(:SERVER :LISP)
X )
X
X;;;----------------------------------------------------------------
X;;; converting the passed string to an s-exp: error handling:
X;;; If you encounter an unknown package, just create it.
X;;;----------------------------------------------------------------
X(defun my-read-external-symbol-not-found-handler (object)
X (sys:proceed object :export))
X(defun my-read-package-not-found-handler (object)
X (sys:proceed object :create-package))
X
X(defun rage-rpc-read-from-string (string)
X (condition-bind
X ((sys:read-external-symbol-not-found 'my-read-external-symbol-not-found-handler)
X (sys:read-package-not-found 'my-read-package-not-found-handler))
X (read-from-string string)))
X
X
X;;;----------------------------------------------------------------
X;;; functions that Sun will call in expecting to find
X;;;----------------------------------------------------------------
X;;; runs on server machine
X(rpc:define-remote-entry give-ap-planning-problem EAR-server
X (:number 1) ;give-ap-planning-problem-proc
X (:arguments (msgs-string string))
X (:values (result rpc:integer-32))
X (:whostate "EAR Give AP the Planning Problem")
X (:lisp
X (:server
X (with-standard-io-environment
X (let* ((*package* (find-package "COMMON-LISP-USER"))
X (*print-readably* nil)
X (msgs (rage-rpc-read-from-string msgs-string))
X )
X (format t "~&Got a planning problem from the sun...~s~&" msgs)
X (rpc:rpc-values EAR-NO-ERROR)
X ))
X ))
X)
X
END_OF_FILE
if test 1939 -ne `wc -c <'sym-serv.lisp'`; then
echo shar: \"'sym-serv.lisp'\" unpacked with wrong size!
fi
# end of 'sym-serv.lisp'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(186 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X.SUFFIXES: .c .h .x
X
X.x.h: $*.x
X rpcgen $*.x
X
Xall: rpcgen.h ear-client
X
Xear-client: ear-client.c rpcgen.h ear.h rpcgen_clnt.c
X cc -target sun4 -o ear-client ear-client.c rpcgen_clnt.c
X
END_OF_FILE
if test 186 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
echo shar: End of shell archive.
exit 0