Set up local tcpserver that conencts to socket

How can we do this?PLease we really need help.

···

--
Posted via http://www.ruby-forum.com/.

http://lmgtfy.com/?q=ruby+socket

···

On Fri, Jun 14, 2013 at 10:48 AM, Rs N. <lists@ruby-forum.com> wrote:

How can we do this?PLease we really need help.

--
Posted via http://www.ruby-forum.com/\.

--
vizualize.me/cliffrosson

That does not help/

···

--
Posted via http://www.ruby-forum.com/.

require 'socket'

server = TCPServer.new 2000 # Server bind to port 2000
loop do
  client = server.accept # Wait for a client to connect
  client.puts "Hello !"
  client.puts "Time is #{Time.now}"
  client.close
end

···

--
Posted via http://www.ruby-forum.com/.

require 'socket'

s = TCPSocket.new 'localhost', 2000

while line = s.gets
   puts line
end

s.close

···

-------
thats the socket

--
Posted via http://www.ruby-forum.com/.

Still doesnt work:(

···

--
Posted via http://www.ruby-forum.com/.

As the question, so the answer.

Or: be more specific, what have you tried, where did you get stuck, ...?

···

Am 14.06.2013 19:55, schrieb Rs N.:

That does not help/

--
<https://github.com/stomar/&gt;

That's an example from the `Socket` documentation. It should work.

And...?

···

Am 14.06.2013 20:01, schrieb Rs N.:

require 'socket'

server = TCPServer.new 2000 # Server bind to port 2000
loop do
   client = server.accept # Wait for a client to connect
   client.puts "Hello !"
   client.puts "Time is #{Time.now}"
   client.close
end

--
<https://github.com/stomar/&gt;

How can we help you? Think about things you can provide us that might help
us figure out where you are getting stuck. Posting your code is a good
start. Help us help you. Right now people are reading your posts and seeing
them as a waste of time.

···

On Fri, Jun 14, 2013 at 11:16 AM, Rs N. <lists@ruby-forum.com> wrote:

Still doesnt work:(

--
Posted via http://www.ruby-forum.com/\.

--
vizualize.me/cliffrosson

And it does! Read about connecting to localhost ... Or ip from diff computer firewall settings etc not just code here ...

···

Sent from my iPhone

On Jun 14, 2013, at 1:07 PM, sto.mar@web.de wrote:

Am 14.06.2013 20:01, schrieb Rs N.:

require 'socket'

server = TCPServer.new 2000 # Server bind to port 2000
loop do
  client = server.accept # Wait for a client to connect
  client.puts "Hello !"
  client.puts "Time is #{Time.now}"
  client.close
end

That's an example from the `Socket` documentation. It should work.

And...?

--
<https://github.com/stomar/&gt;