SDSU CS 596: Client Server Programming
Gopher Protocol

[To Lecture Notes Index]
San Diego State University -- This page last updated February 20, 1995
----------

Contents of Gopher Protocol Lecture

  1. References
  2. Gopher
  3. Gopher+
References The Internet Gopher Protocol by Anklesaria, McCahill, Linder, Johnson, Torry, Alberti, RFC 1436, March 1993

Gopher+ Upward Compatible Enhancements to the Internet Gopher Protocol Anklesaria, Lindner, McCahill, Torry, Johnson, Alberti, July 1993


Gopher

Motivation: Provide easy anonymous access to information

Port: 70

Stateless

Interaction

Client: open connection

Server: accept connection

Client: <selector><CRLF>

Server: <Stuff1><CRLF>

<Stuff2><CRLF>

<StuffN><CRLF>

.<CRLF>

close connection


Using Empty Selector String
Client:
open connection
Server:
accept connection
Client:
<><CRLF>

Tells server to send list of what it has

Server responds with DirEntity (item list)

DirEntity Format

<Type><DisplayString><TAB>
<Selector><TAB>
<Host><TAB>
<PortNumber>
[<TAB><Stuff>]
<CRLF>

DirEntity Example

0About this gopher server<TAB>
0/About this gopher server<TAB>
Saturn.SDSU.Edu<TAB>
70
0About this gopher server 0/About this gopher server Saturn.SDSU.Edu 70
Example of Using Empty Selector

Telnet: open connection on saturn port 70

Server: accept connection

Telnet: <CRLF>

Server:

0About this gopher server	0/About this gopher 	Saturn.SDSU.Edu	70
1Fall1994 Course Schedule	viewcourse CS		gopher.sdsu.edu	91
1Undergraduate CS Major		1/major 		Saturn.SDSU.Edu	70
1CS Master's Exam Info		1/mastersExam		Saturn.SDSU.Edu	70
1CS 596 OOP Fall 94		1/CS596 OOP		Saturn.SDSU.Edu	70
1CS 660 Comb Alg Fall 94	1/CS660			Saturn.SDSU.Edu	70
.


Values for <Type>

0 Item is a file

1 Item is a directory

2 Item is a CSO phone-book server

3 Error

4 Item is a BinHexed Macintosh file.

5 Item is DOS binary archive of some sort.

Client must read until the TCP connection closes.

6 Item is a UNIX uuencoded file.

7 Item is an Index-Search server.

8 Item points to a text-based telnet session.

9 Item is a binary file!

Client must read until the TCP connection closes.

+ Item is a redundant server

T Item points to a text-based tn3270 session.

g Item is a GIF format graphics file.

I Item is some kind of image file.

Client decides how to display.

Characters '0' through 'Z' are reserved.


Using Selector String

Telnet: open connection on saturn port 70

Server: accept connection

Telnet: 1/major<CRLF>

Server:

0Undergraduate Advisors			0/major/advising	Saturn.SDSU.Edu	70
0Required courses for a CS major	0/major/required	Saturn.SDSU.Edu	70
0Elective courses for a CS major	0/major/electives	Saturn.SDSU.Edu	70
0CS499 as an elective 			0/major/499		Saturn.SDSU.Edu	70
1Articulation agreements 		1/major/artic		Saturn.SDSU.Edu	70
.

Fun with Selectors

Telnet: open connection on gopher.sdsu.edu port 91

Server: accept connection

Telnet: <CRLF>

Server:

<Type><DisplayString> <Selector> <Host>

<Type><DisplayString>		<Selector>	<Host>
0About this Gopher		about	gopher.sdsu.edu	91
0Help				help	gopher.sdsu.edu	91
7Class title search		class	gopher.sdsu.edu	91
7Instructor search		instr	gopher.sdsu.edu	91
7Sound alike instructor search	xinstr	gopher.sdsu.edu	91
7Schedule number search		sched	gopher.sdsu.edu	91
7Search entire schedule		all	gopher.sdsu.edu	91
7Search open classes by title 	avail	gopher.sdsu.edu	91
.


Gopher+

Extend Gopher protocol to support:

Pictures
Sounds
Movies
Allow server to
send error messages
improve data transmission
Support Item attribute information

Gopher+ DirEntity Format

<Type><DisplayString><TAB>
<Selector><TAB>
<Host><TAB>
<PortNumber><TAB>
+
<CRLF>

DirEntity Example

0About this gopher server<TAB>
0/About this gopher server<TAB>
Saturn.SDSU.Edu<TAB>
70
+
0About this gopher server 0/About this gopher server Saturn.SDSU.Edu 70 +
Gopher+ Selector String

Client: open connection

Server: accept connection

Client: <selector><TAB>+<CRLF>

Possible Server Responses

  • +<NumberOfBytes><CRLF><data> close connection
  • +-1<CRLF><data><CRLF>.<CRLF> close connection
  • +-2<CRLF><data> close connection
  • --1<CRLF><error message><CRLF>.<CRLF>
Server Error Messages

1
Item Not available
2
Try again later
3
Item has been moved, use XXX

Gopher+ Selector String Example

Telnet: open connection on saturn port 70

Server: accept connection

Telnet: 1/major<TAB>+<CRLF>

Server:

+-1

0Undergraduate Advisors 0/major/advising Saturn.SDSU.Edu 70 + 0Required courses for a CS major 0/major/required Saturn.SDSU.Edu 70 + 0Elective courses for a CS major 0/major/electives Saturn.SDSU.Edu 70 + 0CS499 as an elective 0/major/499 Saturn.SDSU.Edu 70 + 1Articulation agreements 1/major/artic Saturn.SDSU.Edu 70 + .


Attribute Information

Client: open connection

Server: accept connection

Client: <selector><TAB>!<CRLF>

Server: returns the attribute information for the item indicated in the selector

Attribute Format

+<AttributeName>:<data>

Required Attributes

+INFO: <selector>
+ADMIN:
Admin: [comment] <administrator e-mail address>
Mod-Date: [comment] <YYYYMMDDhhmmss>
[Optional stuff]
+VIEWS: [gopher descriptor]
Content-Type[ viewLanguage]: [<size>]

Content-Type Text/plain application/postscript

image/gif etc

Content-Type En_US De_DE,


Attribute Information Example

Telnet: open connection on saturn port 70

Server: accept connection

Telnet: 1/major<TAB>!<CRLF>

Server:

+-1

+INFO: 1Undergraduate CS Major 1/major Saturn.SDSU.Edu 70 +

+ADMIN:

Admin: Computer Science <whitney@saturn.sdsu.edu>

Mod-Date: Fri Sep 16 09:44:18 1994 <19940916094418>

Access: read

+VIEWS:

application/gopher-menu En_US: <.5k>

application/gopher+-menu En_US: <.5k>

+PROTOCOLS:

gopher

gopher+

gopher+/meta

.


Attributes for all items in a Directory

Client: open connection

Server: accept connection

Client: <selector><TAB>$<CRLF>

Specifying the Attributes of Interest

Client: open connection

Server: accept connection

Client: <selector><TAB>$+VIEWS+ABSTRACT<CRLF>


"Interactive Query Items"

DirEntity format for query

<Type><DisplayString><TAB>
<Selector><TAB>
<Host><TAB>
<PortNumber><TAB>
?
<CRLF>

DirEntity Example

0Registration
0/facstaff/Rosters/Reg admissions.sdsu.edu 70 ?

ASK attribute contains questions for client to show user

+ASK:

Note: Electronic Roster Registration

Note:

Ask: Last Name:

Note:

Ask: First Name:

Note:

Ask: Fac/Staff ID# (SS#):

Note:

Ask: Phone Number:

Note:

Ask: E-mail Address:

Note:

Ask: Department(s):

Note:

Choose: Type: Faculty Staff


Some Query Options

AskL

presents the user with a question, and ideally should allow the user to enter several lines of response.

AskF"

requests the user for a new local filename

AskP

presents the user with a question, and bullets out the response typed in by the user

Select

presents the user with a set of options from which the use can select one or many

Choose

presents the user with a set of options from which the use can select one

How Queries work

User selects item in Client that has ? extension

Client gets ask attribute for item from server

Server disconnects

Client displays questions to user, gets answers

Client relays answers to server!!!!


Full Gopher+ Client Request

<selector><TAB>

+[representation]

[<TAB><dataFlag>]<CRLF>

[dataBlock]

OCTET = $00 -> $ff

UNASCII = OCTET - [TAB, CRLF, NUL ]

representation = 'Text' | 'List' | 'Postscript' | 'MacWriteII |

'RTF | {UNASCII}

dataFlag = 0 means no data block

= 1 means has data block

Success = '+' | '-'

Transfer ::= DigitSeq | '-1' | '-2'

DataHead ::= Success Transfer CRLF

DataBlock ::= DataHead {OCTET}