Documents
Home
White paper
Paper
UBF(A) spec
UBF(B) spec
UBF(C) spec

Tutorials
Quick start
Erlang servers
Java clients

Services
IRC
Message Box
File server

Downloads
Downloads

Quick start
2002-03-05
Quick start with UBF

This will jump start you with UBF.

All you need is an internet connection and Telnet to get started.

First read the contract - in the next section. Then fire up Telnet and investigate the server (by hand) - then you can see what's really going on
The Contract

+NAME("file_server").

+VSN("ubf1.0").

+TYPES

info()         = info;
description()  = description;
services()     = services;
contract()     = contract;

file()         = string();
ls()           = ls;
files()        = {files, [file()]};
getFile()      = {get, file()};
noSuchFile()   = noSuchFile.


+STATE start 
       ls()      => files()     & start;
       getFile() => binary()    & start
		 | noSuchFile() & stop.


+ANYSTATE
	info()        => string();
	description() => string();
	contract()    => term().



A telnet session

The following is a telnet session.

User input is in red.

Comments are in blue. Server output is in black, some lines have been omitted:

    
    Set up a connection
    telnet enfield.sics.se 2000
    telnet localhost 2000
    Trying 127.0.0.1...
    Connected to localhost.localdomain.
    Escape character is '^]'.
    {'ubf1.0',"meta_server","
    
     see http://www.sics.se/~joe/ubf/ for details of this service
     type 'info'$ for information
    
    
    "}$
    Ask for information
    'info'$
    
    {"I am a meta server - 
    
        type 'help'$
    
    to find out what I can do",'start'}$
    
    Ask for a list of servers
    'services'$
    {#"test_server"&"irc_server"&"file_server"&,'start'}$
    
    Activate a service
    {'startService',"file_server",#}$
    {{'ok',"I am a mini file server"},'start'}$
    
    Ask for information - note this
    has now changed since we are now talking to a different service
    'info'$
    {"I am a mini file server",'start'}$
    
    Ask for the long description - note this
    has now changed since we are now talking to a different service
    'description'$
    {"
    
    Commands:
    
        'ls'$  List files
        {'get' File} => Length ~ ... ~ | noSuchFile
        
    ",'start'}$
    
    Do a list command
    'ls'$
    {{'files',#"ubf.erl"&"client.erl"&"Makefile"& ...
    
    Fetch a file
    {'get',"Makefile"}$
    {1274~ ... ~'start'}$
    
    Fetch the contract - this is the UBF(A) parse tree
    of the UBF(B) contract given above :-)
    {'contract'$
    {'contract',
     {{'name',"file_server"},
      {'info',"I am a mini file server"},
      {'description',"
    
    Commands:
    
        'ls'$  List files
        {'get' File} => Length ~ ... ~ | noSuchFile
    
    "},
      {'services',#},
      {'states',
       #{'start',
         #{'input',{'tuple',#{'prim','file'}&{'constant','get'}&},
         #{'output',{'constant','noSuchFile'},'stop'}&
          {'output',{'prim','binary'},'start'}&}&
         {'input',{'constant','ls'},
         #{'output',
    	{'tuple',
    	  #{'list',{'prim','string'}}&
    	{'constant','files'}&},'start'}&}&}&},
      {'types',	
    	#{'file',{'prim','string'}}&}}}$
    
    
)