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.
 
 
 
 
 
 

27 lines
780 B

  1. require 'socket'
  2. require File.expand_path('../parser.rb', __FILE__)
  3. def start_server(port_number)
  4. server = TCPServer.new port_number
  5. puts "Ruby Server listening on port #{port_number}\n"
  6. loop do
  7. # Start a new thread for each client accepted
  8. Thread.start(server.accept) do |client|
  9. begin
  10. # Get the amount of data to be read
  11. size = (client.readline).to_i
  12. eos = ">}e^"
  13. p = Bitshift::Parser.new client.read(size)
  14. # Get the parsed result
  15. symbols = p.parse
  16. client.puts symbols
  17. client.puts eos
  18. ensure
  19. # Close the socket
  20. client.close
  21. end
  22. end
  23. end
  24. end