A semantic search engine for source code https://bitshift.benkurtovic.com/
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

23 řádky
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