Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > gserverライブラリ > GServerクラス

class GServer

クラスの継承リスト: GServer < Object < Kernel

要約

サーバを実装するためのクラスです。GServer を継承した新しいクラスを定義して使います。 fork ではなくスレッドを使っています。

特異メソッド

定義 説明
in_service?(port, host = GServer::DEFAULT_HOST) -> bool

与えられた host と port で GServer オブジェクトが同じプロセス内で サービス中なら真を返します。

new(port, host = GServer::DEFAULT_HOST, maxConnections = 4, stdlog = $stderr, audit = false, debug = false)

GServer オブジェクトを生成します。

stop(port, host = DEFAULT_HOST) -> ()

与えられた host と port に対応する GServer オブジェクトを停止します。

インスタンスメソッド

定義 説明
audit -> bool

真であれば、サーバの起動時、接続時、切断時、停止時にログを出力します。

audit=(bool)

真を指定すると、サーバの起動時、接続時、切断時、停止時にログを出力します。

connecting(client) -> true

GServer#audit が真ならば、クライアント接続時に呼ばれます。

connections() -> Fixnum

現在接続しているクライアントの数を返します。

debug -> bool

デバッグモードなら真、そうでないなら偽を返します。

debug=(bool)

真を指定するとデバッグモードが有効になります。 偽を指定するとデバッグモードが無効になります。

disconnecting(clientPort) -> ()

GServer#audit が真ならば、クライアントとの接続終了時に呼ばれます。

error(detail) -> ()

GServer#debug が真の場合、例外が発生すると呼ばれます。

host -> String

ホストを文字列で返します。

join

サーバのサービスを実行しているスレッドを Thread#join します。

log(msg) -> ()

与えられた文字列をログに記録します。

maxConnections -> Fixnum

受け付ける最大接続数を返します。

port -> Fixnum

ポートを数で返します。

serve(io) -> nil

何もしません。サブクラスでオーバーライドします。

shutdown -> true

自身を停止します。

start(maxConnections = -1) -> self

自身を起動します。

starting -> ()

GServer#audit が真ならば、サーバ起動時に呼ばれます。 サブクラスでオーバーライドします。

stdlog -> IO

ログを出力する先の IO オブジェクトを返します。デフォルトは $stderr です。

stdlog=(io)

ログを出力する先の IO オブジェクトを設定します。

stop -> ()

自身をすぐに停止します。

stopped? -> bool

自身が停止しているなら真を返します。

stopping -> ()

GServer#audit が真ならば、サーバ停止時に呼ばれます。 サブクラスでオーバーライドします。

定数

定義 説明
DEFAULT_HOST -> String

"127.0.0.1" です。

継承したメソッド

== === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style untaint