Vishnu A Venu
Vishnu A Venu

Reputation: 1

i am getting error [ socket.gaierror :[Errno 11004] getaddrinfo failed]

Here the code snippet:

import socket,sys


s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

MAX = 65535
PORT = 6000

if sys.argv[1:]==['server']:
    s.bind(('127..0.0.1',PORT))
    print 'Listnening at ',s.getsockname()
    while True:
        data ,address = s.recvfrom(MAX)
        s.sendto('Your data was %d bytes' %len(data),address)
elif sys.argv[1:] == ['client']:
    print 'Address before sending'.s.getsockname()
    s.sendto('This is my message ',('127.0.0.1',PORT))
    print 'Address after sending ',s.getsockname()
    data,address = s.recvfrom(MAX)
    print 'The Server ',address,'   says',repr(data)

else:
    print >>sys.stderr, 'Usage: udp_local.py server|client'

I am getting error [ socket.gaierror :[Errno 11004] getaddrinfo failed]

Upvotes: 0

Views: 7626

Answers (1)

mike
mike

Reputation: 1764

Just replace this line:

s.bind(('127..0.0.1',PORT))

with this:

s.bind(('127.0.0.1',PORT))

Upvotes: 4

Related Questions