Kr Alfabeta wrote:
> hi,
>
> I have been googling for about two hours to solve problem with sockets
> connect method. I need to check connection to server
> www.example.com:xxxx (UDP)
> but the problem is that the answer (connected, refused or smth..)
> returns only with @socket.print "smth" + @socket.recv. (@socket.connect
> only takes the port and address for using when @socket.print is called)
>
> The problem is that I don't know what I should print there. I just need
> to check the connection.
>
> In PHP there are very simple solution:
> $fp = fpsockopen(....)
> if ($fp) return true; else return false;
>
> and just then you can send and receive data.
> Maybe there are any solutions within sockets?
>
> Sorry for my english! :)
>   

If socket.connect does not succeed, it will raise an error, otherwise 
you should be good to go. See the documentation here 
(http://ruby-doc.org/stdlib/libdoc/socket/rdoc/classes/Socket.html) and 
here (http://ruby-doc.org/stdlib/libdoc/socket/rdoc/classes/Socket.html).

Does that help?

-Justin