A semantic search engine for source code https://bitshift.benkurtovic.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
608 B

  1. require 'socket'
  2. require File.expand_path('../parser.rb', __FILE__)
  3. server = TCPServer.new 5003
  4. loop do
  5. # Start a new thread for each client accepted
  6. Thread.start(server.accept) do |client|
  7. begin
  8. # Get the amount of data to be read
  9. size = (client.readline).to_i
  10. p = Bitshift::Parser.new client.read(size)
  11. # Get the parsed result
  12. symbols = p.parse.to_s
  13. client.puts [symbols.length].pack('c')
  14. client.puts symbols
  15. ensure
  16. # Close the socket
  17. client.close
  18. end
  19. end
  20. end