Where “ip” and “port” are the provided ip and port of the server
respectively.
I am told that once the connection is established I will receive a
greeting from the server. I was expecting to find that greeting in
my_socket. Instead the contents of my_socket looks like this:
I am told that once the connection is established I will receive a
greeting from the server. I was expecting to find that greeting in
my_socket. Instead the contents of my_socket looks like this:
Ahh! I get it. (I said that I was green at this.) I now have it
working except that it is REALLY slow.
Can you post some more of the code?
Here is my code that is now working:
require 'socket'
socket=TCPSocket::open("ip","port")
out=File.open('/tmp/debug1','w')
while line=socket.gets
out.puts(line.chop)
end
socket.close
out.close
Do you have any idea why this would be very slow? Thanks.
socket=TCPSocket::open(“ip”,“port”)
out=File.open(‘/tmp/debug1’,‘w’)
while line=socket.gets
out.puts(line.chop)
end
socket.close
out.close
Do you have any idea why this would be very slow? Thanks.
It’s hard to say with no information, but it can be a slow connection.
I know there’s a way to get the data asynchronously. I’ve even used it
but a while ago, I should take a look at that code to point it to you,
but this will avoid the while loop.
I think that I have the speed issue resolved. It appears to be an
anomaly that is associated only with their sandbox server. The live
server seems to work just fine. I can live with that. Thanks for
your help.
On Fri, Jun 11, 2010 at 2:15 PM, Leonardo M. [email protected] wrote:
require ‘socket’
It’s hard to say with no information, but it can be a slow connection.
I know there’s a way to get the data asynchronously. I’ve even used it
but a while ago, I should take a look at that code to point it to you,
but this will avoid the while loop.
You can check the code on one of my github repositories.
It is an unfinished project but that part works.
Take a look at the run method there.
That’s for a server socket but might help you otu with this.
Hope it helps.
–
Leonardo M…
There’s no place like ~
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.