How do I connect to a server?


To access a OKBC server, a client application typically undertakes the following steps. First, the application must establish a connection to an OKBC server (using establish-connection). Second, the application may find out the set of KRSs that the server supports on that connection (using get-kb-types). Third, the application can get information about the KBs of a given type that can be opened on the connection (using openable-kbs). Finally, the application can either open a specific KB (using open-kb) or create a new one (using create-kb).

There could be different types of connection:

  1. Direct connections to local KBs through the local-connection connection type.
  2. Networked connections to simple, single-threaded, unauthenticated OKBC network servers using the simple-network-connection connection type.
  3. Networked connections to the multi-threaded, authenticated OKBC network server provided by the KSL for Ontolingua using the ksl-network-connection connection type.
In the case of a simple connection, for instance, the arguments of establish-connection are simply the host and the port.
Let us take the example of a KSL network connection

(multiple-value-setq (key session-id)
  (ksl-okbc:login-user-and-create-session 
   "www-ksl-svc.stanford.edu"		;port
   5915					;port
   "user"				;user-id
   "********"				;password
   :just-me				;group
   ""					;description
   100)					;duration
  )

USER(1): "4PPZoabZralOk4P8ipe0wrNjnM4P2C2cw36CJYY4P156VNwCdPEA"

(setq connection
  (okbc:establish-connection 
   'ksl-okbc:ksl-network-connection
   :initargs (list :host       "www-ksl-svc.stanford.edu"
		   :port       5915	
		   :user-id    "user"
		   :password   "********"	
		   :session-id session-id
		   :key        key
		   :kb-library :a)))

USER(2): #< KSL-OKBC:KSL-NETWORK-CONNECTION @ #x1dedc32>

(setq kb-types 
  (okbc:get-kb-types :connection connection))

USER(3): 
(#< OK-BACK::ATP-OKBC-KB-NETWORK-KB Prototype @ #x1df0c12> 
 #< OK-BACK::CLOS-KB-NETWORK-KB Prototype @ #x1df504a>
 #< OK-BACK::DOMAIN-THEORY-NETWORK-KB Prototype @ #x1df6282> 
 #< OK-BACK::EQUATION-MODEL-NETWORK-KB Prototype @ #x1df74ba>
 #< OK-BACK::META-KB-NETWORK-KB Prototype @ #x1dfb452> 
 #< OK-BACK::ONTOLOGY-NETWORK-KB Prototype @ #x1dfc65a>
 #< OK-BACK::TUPLE-KB-NETWORK-KB Prototype @ #x1e00612>)

(setq kb-type (nth 5 kb-types))

USER(4): #< OK-BACK::ONTOLOGY-NETWORK-KB Prototype @ #x1dfc65a>

(setq kbs (okbc:openable-kbs :kb-type kb-type :connection connection))

USER(5): (#< OK-BACK:REMOTE-VALUE 429319187:66320547 @ #x1e0337a> #< OK-BACK:REMOTE-VALUE 429319187:66320548 @ #x1e0342a>
 #< OK-BACK:REMOTE-VALUE 429319187:66320549 @ #x1e034ca> ...)

(loop for kb in kbs do 
      (print (okbc:get-frame-name kb :kb 
				  (okbc:meta-kb :connection connection))))

USER(6): 
Q|ONTOLINGUA-USER::WORLD-FACT-BOOK.NATURAL-RESOURCES.REDUNDANT-TERMS 
Q|ONTOLINGUA-USER::WORLD-FACT-BOOK.NATURAL-RESOURCES 
Q|ONTOLINGUA-USER::WORLD-FACT-BOOK 
Q|ONTOLINGUA-USER::WORLD-FACT-BOOK.CP-COUNTRIES 
Q|ONTOLINGUA-USER::VEHICLES-TUTORIAL 
...
NIL

(setq kb-locator (nth 2 kbs))

USER(7): #< OK-BACK:REMOTE-VALUE 429319187:66320549 @ #x2188412>

(setq kb (okbc:open-kb kb-locator :kb-type kb-type :connection connection))

USER(8): #< OK-BACK::ONTOLOGY-NETWORK-KB Q|ONTOLINGUA-USER::WORLD-FACT-BOOK on #< KSL-NETWORK-CONNECTION> @ #x260b672>

(okbc:goto-kb kb)

USER(9): 1000 2000 3000 4000 
T

Next: How do I specify a knowledge base within a server?
Top: OKBC FAQ Table of Contents