Question

I use GPRS WRX700-R http://gsm-gate.ru/product/gprs-terminal-teleofis-wrx700-r/ and it's program enter image description here (Sorry it is in Russian) You can write ip and port address to send bytes to the server. I write ftp ip and port number of my server. And it sends data. But on the server, I don't know where this bytes come. Can I write program on server that open sockets and get these bytes? If yes, how?

Was it helpful?

Solution

You can use a simple web server for example WEBrick to listen certain port. Ruby code would be(http://www.ruby-doc.org/stdlib-2.0/libdoc/webrick/rdoc/WEBrick.html):

require 'webrick'

server = WEBrick::HTTPServer.new :Port => 8000
trap 'INT' do server.shutdown end

server.start

Then you can take request and do whatever you want with the data sent:

server.mount_proc '/' do |req, res|
    do_what_you_want(req)
    res.status = 200
    res.body = 'OK'
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top