#! /usr/bin/env python3

import socket
import signal
import logging
import argparse

parser = argparse.ArgumentParser(description='Client')
parser.add_argument('port', type=int, help='Server port')
parser.add_argument('ip', help='Server ip')
parser.add_argument('-v', '--verbose', action='count', help='Enable debugging')
args = parser.parse_args()

logging.basicConfig(format='%(asctime)s %(levelname)s %(pathname)s:%(lineno)d %(msg)s')
log = logging.getLogger()
log.setLevel(logging.INFO - (args.verbose or 0)*10)

signal.signal(signal.SIGPIPE, lambda signum, stack_frame: exit(0))

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
log.info(f'Connecting to {args.port} at {args.ip!r}...')
sock.connect((args.ip, args.port))
log.info('Connected!')
sock.close()
