getsockaddarg() error when using UDP sockets
<p>I am trying to create a simple UDP connection, but fail miserably every time. I am using Python 3.5.2 with PyCharm.
        import socket
    from socket import AF_INET, SOCK_DGRAM</p>

<pre><code>ip = tuple(input('Enter an ip\n'))
#time = int(input('How long? In seconds \n'))
msg = 'Hello'
addr = (ip, 80)

def connection():
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(ip)
    sock.sendto(msg, addr)


connection()
</code></pre>

<p>The error I get is:</p>

<pre><code>Traceback (most recent call last):
  File "A:/PycharmProjects/udp.py", line 15, in &lt;module&gt;
    connection()
  File "A:/PycharmProjects/udp.py", line 11, in connection
    sock.bind(ip)
TypeError: getsockaddrarg() takes exactly 2 arguments (14 given)

Process finished with exit code 1
</code></pre>

<p>Calling <code>tuple</code> will construct a tuple containing each individual character in the iterable (the input string):</p>

<pre><code>&gt;&gt;&gt; tuple('127.0.0.1')
('1', '2', '7', '.', '0', '.', '0', '.', '1')
</code></pre>

<p>Don't use <code>tuple</code> just use the input you receive:</p>

<pre><code>ip = input('Enter an ip\n')
msg = 'Hello'
addr = (ip, 80)
</code></pre>

<p>and bind on it:</p>

<pre><code>sock.bind(addr)
</code></pre>

python sockets python-3.x