tcpsocket

Ruby TCPSocket keeps losing connection

I have a client and server. I start up the server, and run the client, and the first time it works fine. The second time I run the client(without restarting the server), the client appears to hang. Can anyone see what is wrong? I have a client: # Code example originated from p069dtclient.rb at http://rubylearning.com/satishtalim/r...

ruby socket question ....

i'm still kind of newbie to ruby, but i became used on using ruby sockets, cause i used the 'Socket' class many times, and so i having full control to my sockets and their options. the thing is i'm trying to make it a little easy for me, so i'm trying to use the 'TCPSocket' class ,witch (i guess) doesn't give u much control as the 'Sock...

Ruby TCPSocket recv blocking and never returning.

So, I have the following code: def LSCPHandler.send_message(message, hostname, port) s = TCPSocket.open(hostname, port) s.print message ret = s.recv(1024) s.close LSCPHandler.parse_error(ret) return ret end Which works just fine, normally. The server I'm talking to returns the response pretty quickly, usually, and all is well. ...

Send more than 32768 Bytes at once from one TCP-Socket to an other

Hey guys, I don't know if this question has been asked yet but imagine following situation: I have two TCP-Sockets (opened with NSSocketPort und listening with two NSFileHandle) and now I want to send some NSData between them. @try { [fileHandle writeData:data]; } @catch (NSException * e) { // Do some alert } Everything is ri...

Ruby TCPServer sockets

Maybe I've gotten my sockets programming way mixed up, but shouldn't something like this work? srv = TCPServer.open(3333) client = srv.accept data = "" while (tmp = client.recv(10)) data += tmp end I've tried pretty much every other method of "getting" data from the client TCPSocket, but all of them hang and never break out of th...

ruby socket programming using credentials

HI folks, I'm trying to establish connection to a remote server using ruby socket connection TcpSocket. I started with TcpSocket.new(port,host) Now, How do I pass the credentials to it. The remote server needs credentials to allow me to connect. Any help is very much appreciated. Thanks ...

How to handle Timeouts in Ruby with TCPSocket networking

I want to be able to return quickly from a networking call that times out (having seen that my code can hang forever if the network is down, or similar) My code looks like: s = TCPSocket.open(hostname,port) s.puts msg ret = s.recv(1024) s.close I'm pretty confused at the documentation for TCPSocket, for example, doesn't even MENTION ...

Ruby TCPSocket: Find out how much data is available

Is there a way to find out how many bytes of data is available on an TCPSocket in Ruby? I.e. how many bytes can be ready without blocking? ...