6 kyu

Basic socket server

166 of 195potzko
Description
Loading description...
Backend
  • Please sign in or sign up to leave a comment.
  • buraska Avatar

    Hi, great topic, but I met some problems. I was writting in java.

    1.I dont understand how could I throw IOException. I simply close the connection, but tests say "Expected java.io.IOException to be thrown, but nothing was thrown" When I add exception signature test does not work. I dont really know what to do. Is it my or tests problem? 2.The description says the port is 1111, but tests works in 80. This is distracting .

  • saudiGuy Avatar

    Python : I don't know if it's just me, but it seems like most of the solutions aren't working.

  • trashy_incel Avatar

    Python full tests:

    • basic_tests() should be decorated with @test.describe('basic tests')
    • as a consequence, basic_tests() should not be called explicitely
    • random_check() and exit_check() should be it blocks, not describe blocks
  • ParanoidUser Avatar

    One more thing: Although port 80 is the default HTTP port, in most cases, it's already being used by another server. Which puts this kata at risk of port collision. I'd recommend following the same guideline as implemented for Simple Socket Client and switching to port 1111.

  • ParanoidUser Avatar

    nitpick: a minor typo in the description - other th[A]n "exit"

  • jekasachan Avatar

    Thank you very much for this kata. Having some trouble figuring out networking and i had a lot of fun clearing some stuff up step by step with this one.

  • Unnamed Avatar

    If the user sends a string containing only the word "exit"...

    This requirement is impossible for a stream-oriented protocol. If I send every byte as soon as it arrives, the tests fail. If I pause sending when "e" is received until I can make sure it's not followed by "xit", the tests fail too.

  • Unnamed Avatar

    The tests output still contains headers with red arrows.

  • Unnamed Avatar

    The required protocol isn't specified, but seems to be TCP. It's impossible to receive a packet using a stream-oriented protocol.

  • Voile Avatar

    Random tests is improperly using the testing framework. Please note the proper usage of the testing framework: You're supposed to put test assertions inside test.it, not test.describe (however you can nest test.describe more than once before any test.it), and each test.it block should have at least 1 test assertion.

  • Voile Avatar

    What is the maximum message length? Almost every solution (including author setup on all the current socket katas) doesn't actually ensure the full message is received before processing the message. This will cause problems for specifically crafted inputs.

  • Voile Avatar

    Create a socket that listens on port 80

    Listen to which host? For the purpose of the kata 127.0.0.1/localhost is fine, but this will not be fine for actual use of the socket by anyone else; and listening to any host is kinda a bad idea. So at least this should be specified.

  • 4500zenja1 Avatar

    I think basic_tests function should be wrapped into @test.describe('smth') — with the deletion of the function call at the end, of course :)

    Also, is it normal that I get the following error:

    Exception in thread Thread-1 (socket_server):
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
        self.run()
      File "/usr/local/lib/python3.10/threading.py", line 946, in run
        self._target(*self._args, **self._kwargs)
      File "/workspace/default/solution.py", line 11, in socket_server
        s = con.recv(1024).decode()
    OSError: [Errno 9] Bad file descriptor
    

    I think that's the part of checking if the connection has been closed, but maybe that should be written in the description, smth like Ignore the stderr output?

    Double-also, why is client.send("did you close the connection?") without .encode()? If I try to put it, my solution will crash, because the server will be "working" and thus calling test.fail(...) =/