アゲイン

Pine と Gopher でネットに目覚めたエンジニアの卵が、18年後に再度初心に返るブログ

Gopher クライアントを作りたい(2)

Gopher クライアントを自分でも作ってみたいと思い立ったわけですが、何から手をつけたらいいのか。。
 
  • ネットで公開されている先人の書かれたコードを打ち込んで、コードから理解を始める
    (こんなにまとまってる所もあったりするし・・)
  • RFC1436 を読んでみる

あたりが、パッと思いついたとっかかりなのですが、今回は RFC から入りたい心境なので後者をやってみます。

 

 

RFC 1436 を読みながら、気になったところをメモしてみます

  • Gopher は Client-Server モデル <Introduction>
     
  • TCP/IP で通信し、ポートは IANA によって 70 番Gopher 用に割り当てられている <Introduction>
     
  • Gopherファイルシステムがドキュメント管理に適していると考え、ネット上に分散している情報やディレクトリを階層構造にして、ユーザーに見せる <Introduction>
     
  • Gopher プロトコルはシンプル。 Telnet を使うことでも gopher client をシミュレート可能 <1.  Introduction - (b)>

  • 基本作法 =
    『70番ポートで接続』
    『<CR><LF>送信すると、接続先サーバの持っている情報リストが返ってくる』
    『クライアントからの様々なコマンド送信によって結果が返ってくる』
    『サーバーはドキュメントの最後の行でドット(.) を送信し、コネクションを切断する』
     Client:          {Opens connection to rawBits.micro.umn.edu at port 70}
    
     Server:          {Accepts connection but says nothing}
    
     Client: <CR><LF> {Sends an empty line: Meaning "list what you have"}
    
     Server:          {Sends a series of lines, each ending with CR LF}
     0About internet GopherFStuff:About usFrawBits.micro.umn.eduF70
     1Around University of MinnesotaFZ,5692,AUMFunderdog.micro.umn.eduF70
     1Microcomputer News & PricesFPrices/Fpserver.bookstore.umn.eduF70
     1Courses, Schedules, CalendarsFFevents.ais.umn.eduF9120
     1Student-Staff DirectoriesFFuinfo.ais.umn.eduF70
     1Departmental PublicationsFStuff:DP:FrawBits.micro.umn.eduF70
                        {.....etc.....}
     .                  {Period on a line by itself}
                        {Server closes connection}
    

     <2.  The internet Gopher Model> 

  • 情報リストの先頭 1 文字は、『ドキュメント』『ディレクトリ』もしくは『検索サービス』を指し、それぞれ 0, 1, 7 に対応している <2.  The internet Gopher Model>
    この 1 文字のことを "Item type character" と呼ぶ <3.8  Item type characters>

  • コマンドや行の終了を意味するのが <CR><LF> <2.  The internet Gopher Model>  
     
  • 上の情報リストを受け、ユーザーは以下の様にすることで目的のドキュメントを発見できる <2.  The internet Gopher Model>
        Client:           (Connects to pserver.bookstore.umn.edu at port 70)
        Server:           (Accepts connection but says nothing)
        Client: Prices/   (Sends the magic string terminated by CRLF)
        Server:           (Sends a series of lines, each ending with CR LF)
        0About PricesFPrices/AboutusFpserver.bookstore.umn.eduF70
        0Macintosh PricesFPrices/MacFpserver.bookstore.umn.eduF70
        0IBM PricesFPrices/IckFpserver.bookstore.umn.eduF70
        0Printer & Peripheral PricesFPrices/PPPFpserver.bookstore.umn.eduF70
                          (.....etc.....)
        .                 (Period on a line by itself)
                          (Server closes connection)
 
  • 各ドキュメントは、selector 文字列、(ドキュメントを保持している)マシンのドメイン名、および IP ポートの 3 つを組み合わせた情報とリンクされている <3.1  Locating services>

  • Item type character が '7' である検索サービスは、(大学や研究機関など)キャンパス内をカバーする検索サーバーを指している。
    検索サーバーに対して、Gopher クライアントは 『selector 文字+TAB+検索クエリ』を送ることで検索結果を得られる。
    検索クエリは、スペースで区切ることができ、通常スペースは AND 条件を意味する
    <3.7  Special purpose servers - 2>
     
  • Item type character の数字は以下を意味する <3.8  Item type characters>
       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.  Beware.
       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.  Beware.
       +   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. 
 
  • Item type が 5 〜 9 の場合、Gopher クライアントはコネクションが切れるまでデータを読み続けることになるので注意 <3.8  Item type characters>

  • (RFP 記述当時は) 1 行が 80 文字のディスプレイが多いので、若干余裕も考慮すると 1 行につき 70 文字以下になるのが望ましい。
    Gopher クライアントは、長すぎる文字列の場合は省略するのもいいだろう <3.9  User display strings and server selector strings>

 

すごくシンプルなんですねぇ。

シンプル過ぎてビックリですが、RFP の最後に『4.   Simplicity is intentional』の章があり、敢えてそうしていることも書かれていました。

 

来週は実装にトライしてみようと思います。

>>> つづく