]> git.madduck.net Git - etc/vim.git/blob - test/script/dumb_tcp_client.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / script / dumb_tcp_client.py
1 """
2 This is just a script for testing that the dumb TCP server actually works
3 correctly, for verifying that problems with tests are in Vim. Pass the
4 same port number given to the test server to check that it's working.
5 """
6 import socket
7 import sys
8
9
10 def main():
11     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12     result = sock.connect_ex(('127.0.0.1', int(sys.argv[1])))
13
14     if result:
15         sock.close()
16         sys.exit("Couldn't connect to the socket!")
17
18     data_sent = 'x' * 1024
19
20     sock.send(data_sent)
21     data_received = sock.recv(1024)
22
23     if data_sent != data_received:
24         sock.close()
25         sys.exit("Data sent didn't match data received.")
26
27     sock.close()
28
29     print("Everything was just fine.")
30
31
32 if __name__ == "__main__":
33     main()