ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux], rails 4.2.4
i using cloud9 ide , webrick server. project track gps in real time.
i want use tcp connection communicate gps tracking device requires transmit data in hexa decimal format 0x01. put following code in controller.
gps device protocol confidential. unable provide here.
my server running on port 8080. device sending data port.
but don't know how write code establish connection between our server , device , how transmit , view data sent device server.
i found on net . don't know whether correct or not.
require 'socket' server = tcpserver.new ("127.0.0.1",8080) loop thread.start(server.accept) |client| client.puts "hello !" client.puts "time #{time.now}" client.close end end
but causes following error.
address in use - bind(2) nil port 8080
if change port shows
bad gatewat error.502
kindly me. in advance.
Comments
Post a Comment