From: Xiangrong Fang Date: 2003-07-29T01:03:11+09:00 Subject: Re: winsock problem? I tried the following, but unfortunately does not work: require 'socket' begin server = Socket.new(Socket::PF_INET, Socket::SOCK_STREAM, 0) server.setsockopt(Socket::SOL_SOCKET, -5, 1) #Socket::SO_EXCLUSIVEADDRUSE n = Socket.gethostbyname("localhost") sockaddr = [Socket::AF_INET, 3456, n[3], 0, 0].pack("snA4NN") server.bind(sockaddr) server.listen(0) rescue Exception => e puts e.message puts e.backtrace.join("\r\n") exit end while session = server.accept do session.print "connected" session.close end On Mon, 28 Jul 2003 22:01:56 +0900 ts wrote: > >>>>> "X" == Xiangrong Fang writes: > > X> How can I use the binding mode in Ruby? I use TCPServer. which seems is > X> a very high level wrapper. I also tried to look for TCPServer.rb, but I > X> can't find it. Seems that the TCPServer class is a build in module of > X> Ruby intepretor. > > a call to setsockopt() before the call to bind() > > > Guy Decoux > > > > -- Xiangrong Fang