repo.or.cz
/
ruby-svn.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
* transcode.c (econv_init): accept Encoding object as source_encoding
[ruby-svn.git]
/
sample
/
tsvr.rb
blob
52cdd32dce204ad021e706c185009a2e387de16e
1
# socket example - server side using thread
2
# usage: ruby tsvr.rb
3
4
require "socket"
5
6
gs = TCPserver.open(0)
7
addr = gs.addr
8
addr.shift
9
printf("server is on %s\n", addr.join(":"))
10
11
loop do
12
Thread.start(gs.accept) do |s|
13
print(s, " is accepted\n")
14
while line = s.gets
15
s.write(line)
16
end
17
print(s, " is gone\n")
18
s.close
19
end
20
end