import socket


def validate_args(args):
    """ Checks if the arguments are valid or not. """
    # Is the number of sockets positive ?
    if not args.number > 0:
        print("[ERROR] Number of sockets should be positive. Received %d" % args.number)
        exit(1)
    # Is a valid IP address or valid name ?
    try:
        servers = socket.getaddrinfo(args.address, args.port, proto=socket.IPPROTO_TCP)
        return servers[0]
    except socket.gaierror as error:
        print(error)
        print("Please, provide a valid IPv4, IPv6 address or a valid domain name.")
        exit(1)