blob: fcc847f265f2dc35713b7cf0e08ebd7d5d0521a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# $Id: server_1_grid.rb,v 1.2 2006-03-15 04:40:47 matju Exp $
require "socket"
require "smpte" # in this folder
picture = "\x7fGRID \000\003"
picture << [240,320,3].pack("N*")
make_smpte(picture) {|*rgb| rgb.pack "N*" }
# File.open("blah.grid","w") {|f| f.write picture }
serv = TCPServer.new 4242
loop {
puts "waiting for connection (port 4242)"
sock = serv.accept
puts "incoming connection"
begin
loop {
sock.write picture
puts "wrote one picture"
}
rescue Errno::EPIPE # Broken Pipe
puts "connection closed (by client)"
# it's ok, go back to waiting.
end
}
|