Class: IPSocket
- Inherits:
-
Object
- Object
- IPSocket
- Defined in:
- lib/vapir-firefox/firefox_socket/base.rb
Overview
:startdoc:
Instance Method Summary collapse
-
#ready_to_recv?(timeout) ⇒ Boolean
takes a timeout, and returns true if Kernel.select indicates that the socket is ready to read within that timeout.
-
#sendall(message, flags = 0) ⇒ Object
sends the whole message .
Instance Method Details
#ready_to_recv?(timeout) ⇒ Boolean
takes a timeout, and returns true if Kernel.select indicates that the socket is ready to read within that timeout. if Kernel.select indicates that the socket is in an error condition, this method will raise
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vapir-firefox/firefox_socket/base.rb', line 61 def ready_to_recv?(timeout) select_result = Kernel.select([self], nil, [self], timeout) read_result, write_result, err_result = *select_result if select_result && err_result.include?(self) # never actually seen this condition, so not sure what error class to put here raise "the socket indicated an error condition when checking that it was ready for reading" else return select_result && read_result.include?(self) end end |
#sendall(message, flags = 0) ⇒ Object
sends the whole message
returns the number of broken-up sends that occured.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vapir-firefox/firefox_socket/base.rb', line 48 def sendall(, flags=0) bytes_sent = 0 packets = 0 while bytes_sent < .length send_result = send([bytes_sent..-1], flags) bytes_sent+= send_result packets+= 1 end packets end |