• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python2.7
2# Copyright 2015 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Opens a TCP connection to a specified server and then exits."""
17
18import argparse
19import socket
20import threading
21import time
22import sys
23
24
25def main():
26  argp = argparse.ArgumentParser(description='Open a TCP handshake to a server')
27  argp.add_argument('-s', '--server_host', default=None, type=str,
28                    help='Server host name or IP.')
29  argp.add_argument('-p', '--server_port', default=0, type=int,
30                    help='Port that the server is listening on.')
31  argp.add_argument('-t', '--timeout', default=1, type=int,
32                    help='Force process exit after this number of seconds.')
33  args = argp.parse_args()
34  socket.create_connection([args.server_host, args.server_port])
35
36if __name__ == '__main__':
37  main()
38