Class: IB::IBSocket
- Includes:
- PrepareData
- Defined in:
- lib/ib/socket.rb
Instance Method Summary collapse
- #initialising_handshake ⇒ Object
- #read_string ⇒ Object
- #recieve_messages ⇒ Object
-
#send_messages(*data) ⇒ Object
send the message (containing several instructions) to the socket, calls prepare_message to convert data-elements into NULL-terminated strings.
-
#write_data(data) ⇒ Object
Sends null terminated data string into socket.
Methods included from PrepareData
#decode_message, #prepare_message
Instance Method Details
#initialising_handshake ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ib/socket.rb', line 116 def initialising_handshake v100_prefix = "API".tws.encode 'ascii' v100_version = self. Messages::SERVER_VERSION write_data v100_prefix+v100_version ## start tws-log # [QO] INFO [JTS-SocketListener-49] - State: HEADER, IsAPI: UNKNOWN # [QO] INFO [JTS-SocketListener-49] - State: STOP, IsAPI: YES # [QO] INFO [JTS-SocketListener-49] - ArEServer: Adding 392382055 with id 2147483647 # [QO] INFO [JTS-SocketListener-49] - eServersChanged: 1 # [QO] INFO [JTS-EServerSocket-287] - [2147483647:136:136:1:0:0:0:SYS] Starting new conversation with client on 127.0.0.1 # [QO] INFO [JTS-EServerSocketNotifier-288] - Starting async queue thread # [QO] INFO [JTS-EServerSocket-287] - [2147483647:136:136:1:0:0:0:SYS] Server version is 136 # [QO] INFO [JTS-EServerSocket-287] - [2147483647:136:136:1:0:0:0:SYS] Client version is 136 # [QO] INFO [JTS-EServerSocket-287] - [2147483647:136:136:1:0:0:0:SYS] is 3rdParty true ## end tws-log end |
#read_string ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ib/socket.rb', line 134 def read_string string = self.gets(EOL) until string # Silently ignores nils string = self.gets(EOL) sleep 0.1 end string.chomp end |
#recieve_messages ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/ib/socket.rb', line 163 def begin = [] begin # this is the blocking version of recv buffer = self.recvfrom(4096)[0] # STDOUT.puts "BUFFER:: #{buffer.inspect}" << buffer end while buffer.size == 4096 .join('') rescue Errno::ECONNRESET => e Connection.logger.fatal{ "Data Buffer is not filling \n The Buffer: #{buffer.inspect} \n Backtrace:\n #{e.backtrace.join("\n") } " } Kernel.exit end end |
#send_messages(*data) ⇒ Object
send the message (containing several instructions) to the socket, calls prepare_message to convert data-elements into NULL-terminated strings
154 155 156 157 158 159 160 161 |
# File 'lib/ib/socket.rb', line 154 def *data self.syswrite (data) rescue Errno::ECONNRESET => e Connection.logger.fatal{ "Data not accepted by IB \n #{data.inspect} \n Backtrace:\n "} Connection.logger.error e.backtrace end |
#write_data(data) ⇒ Object
Sends null terminated data string into socket
148 149 150 |
# File 'lib/ib/socket.rb', line 148 def write_data data self.syswrite data.tws end |