This is a multi-part message in MIME format.

------extPart_000_000E_01C25115.0F3B41E0
Content-Type: text/plain;
	charsets-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  CPServer.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
PServer.new 'localhost','9090' con.accept while !con.eof? puts con.gets end (client.rb) require 'socket' ss
PSocket.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 ------extPart_000_000E_01C25115.0F3B41E0 Content-Type: text/html; charsets-ascii" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <TITLE>Message</TITLE> <META content="MSHTML 6.00.2716.2200" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff size=2>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.&nbsp; If you want the server to listen to all devices (localhost, NICs, etc) specify the address:</FONT></SPAN></DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff ize=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff size=2>ss = TCPServer.new '0.0.0.0', 9090&nbsp;&nbsp; # note that the port should be an integer and not a string.</FONT></SPAN></DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff ize=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff size=2>Then the client should work</FONT></SPAN></DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff ize=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff size=2>Hope this helps,</FONT></SPAN></DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff ize=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=491413421-31082002><FONT face=Arial color=#0000ff ize=2>Rich</FONT></SPAN></DIV> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV></DIV> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> mike yin [mailto:zcyin / ee.ualberta.ca] <BR><B>Sent:</B> Saturday, August 31, 2002 5:03 PM<BR><B>To:</B> ruby-talk ML<BR><B>Subject:</B> using TCPServer/TCPSocket implementing server/client application in win32?<BR><BR></FONT></DIV> <DIV><FONT face=Arial size=2>Dear guys:</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=Arial size=2>I hope you can tell me why I can't use TCPSocket implementing server/client application in win32 network environment.</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=Arial size=2>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)'</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=Arial size=2>The server.rb/client.rb are as follows:</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=Arial size=2>(server.rb)<BR>require 'socket'<BR>ss=TCPServer.new 'localhost','9090'<BR>con=ss.accept<BR>while !con.eof?<BR>&nbsp;puts con.gets<BR>end</FONT></DIV> <DIV>&nbsp;</DIV> <DIV><FONT face=Arial size=2>(client.rb)<BR>require 'socket'<BR>ss=TCPSocket.new '192.168.1.10','9090'<BR>&nbsp;ss.puts 'I'<BR>&nbsp;ss.puts 'Have'<BR>&nbsp;ss.puts 'A'<BR>&nbsp;ss.puts 'Dream'<BR>&nbsp;ss.puts '--Chai'</FONT></DIV> <DIV>&nbsp;</DIV><FONT face=Arial size=2> <DIV><BR>What's the problem? what should I use for server/client application in win32 then?</DIV> <DIV>&nbsp;</DIV> <DIV>Thank you very very much.</DIV> <DIV>&nbsp;</DIV> <DIV>Sincerely,<BR>Xinwei</FONT></DIV></BLOCKQUOTE></BODY></HTML> ------extPart_000_000E_01C25115.0F3B41E0--