import socket


def bindsocket(port, host=''):
    """
    Creates a socket assigned to the IP address (host, port).

    Parameters
    ----------
    port : int
        port assigned to the socket.
    host : str, optional
        host assigned to the socket. The default is ''.

    Returns
    -------
    tcpsock : socket
        socket connected at (host, port).

    """
    tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    tcpsock.bind((host, port))
    return tcpsock