From: Rich Kilmer Date: 2002-09-01T06:38:32+09:00 Subject: RE: using TCPServer/TCPSocket implementing server/client application in win32? This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C25115.0F3B41E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_000E_01C25115.0F3B41E0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
In the=20 server you are listening on port 127.0.0.1 (localhost) and the client = tries to=20 connect to your NIC (192.168.1.10) they are different addresses.  = If you=20 want the server to listen to all devices (localhost, NICs, etc) specify = the=20 address:
 
ss =3D=20 TCPServer.new '0.0.0.0', 9090   # note that the port should be = an=20 integer and not a string.
 
Then=20 the client should work
 
Hope=20 this helps,
 
Rich
-----Original Message-----
From: mike = yin=20 [mailto:zcyin@ee.ualberta.ca]
Sent: Saturday, August 31, = 2002 5:03=20 PM
To: ruby-talk ML
Subject: using = TCPServer/TCPSocket=20 implementing server/client application in win32?

Dear guys:
 
I hope you can tell me why I can't = use TCPSocket=20 implementing server/client application in win32 network=20 environment.
 
When both server and client are under = irb, they=20 work well. But in server.rb/client.rb form, just when connecting, the = client=20 get an exception as: 'No connection could be made because the target = machine=20 actively refused it. - "connect(2)" (Errno::E10061)'
 
The server.rb/client.rb are as=20 follows:
 
(server.rb)
require=20 'socket'
ss=3DTCPServer.new = 'localhost','9090'
con=3Dss.accept
while=20 !con.eof?
 puts con.gets
end
 
(client.rb)
require=20 'socket'
ss=3DTCPSocket.new '192.168.1.10','9090'
 ss.puts=20 'I'
 ss.puts 'Have'
 ss.puts 'A'
 ss.puts=20 'Dream'
 ss.puts '--Chai'
 

What's the problem? what should I use for server/client = application=20 in win32 then?
 
Thank you very very much.
 
Sincerely,
Xinwei
------=_NextPart_000_000E_01C25115.0F3B41E0--