Using TCPServer/TCPSocket implementing server/client application in win32?

Dear guys:

I hope you can tell me why I can’t use TCPSocket implementing server/client application in win32 network environment.

When both server and client are under irb, they work well. But in server.rb/client.rb form, just when connecting, the client get an exception as: ‘No connection could be made because the target machine actively refused it. - “connect(2)” (Errno::E10061)’

The server.rb/client.rb are as follows:

(server.rb)
require 'socket’
ss=TCPServer.new ‘localhost’,'9090’
con=ss.accept
while !con.eof?
puts con.gets
end

(client.rb)
require 'socket’
ss=TCPSocket.new ‘192.168.1.10’,'9090’
ss.puts 'I’
ss.puts 'Have’
ss.puts 'A’
ss.puts 'Dream’
ss.puts ‘–Chai’

What’s the problem? what should I use for server/client application in win32 then?

Thank you very very much.

Sincerely,
Xinwei

Are you sure that the server.rb is:
a) running before client.rb runs
b) has time to establish the socket before client.rb tries to connect?

···

On Sun, Sep 01, 2002 at 06:02:35AM +0900, mike yin wrote:

Dear guys:

I hope you can tell me why I can’t use TCPSocket implementing server/client
application in win32 network environment.

When both server and client are under irb, they work well. But in server.rb/
client.rb form, just when connecting, the client get an exception as: ‘No
connection could be made because the target machine actively refused it. -
“connect(2)” (Errno::E10061)’


Alan Chen
Digikata LLC
http://digikata.com

In the server you are listening on port 127.0.0.1 (localhost) and the
client tries to connect to your NIC (192.168.1.10) they are different
addresses. If you want the server to listen to all devices (localhost,
NICs, etc) specify the address:

ss = TCPServer.new ‘0.0.0.0’, 9090 # note that the port should be an
integer and not a string.

Then the client should work

Hope this helps,

Rich

···

-----Original Message-----
From: mike yin [mailto:zcyin@ee.ualberta.ca]
Sent: Saturday, August 31, 2002 5:03 PM
To: ruby-talk ML
Subject: using TCPServer/TCPSocket implementing server/client
application in win32?

Dear guys:

I hope you can tell me why I can’t use TCPSocket implementing
server/client application in win32 network environment.

When both server and client are under irb, they work well. But in
server.rb/client.rb form, just when connecting, the client get an
exception as: ‘No connection could be made because the target machine
actively refused it. - “connect(2)” (Errno::E10061)’

The server.rb/client.rb are as follows:

(server.rb)
require 'socket’
ss=TCPServer.new ‘localhost’,'9090’
con=ss.accept
while !con.eof?
puts con.gets
end

(client.rb)
require 'socket’
ss=TCPSocket.new ‘192.168.1.10’,'9090’
ss.puts 'I’
ss.puts 'Have’
ss.puts 'A’
ss.puts 'Dream’
ss.puts ‘–Chai’

What’s the problem? what should I use for server/client application in
win32 then?

Thank you very very much.

Sincerely,
Xinwei