[New-bugs-announce] [issue2763] A socket example code shown in doc doesn't work on FreeBSD
Giampaolo Rodola'
report at bugs.python.org
Sun May 4 23:51:53 CEST 2008
New submission from Giampaolo Rodola' <billiejoex at users.sourceforge.net>:
This is the result from executing the second IPv4/IPv6 server example
shown in socket module documentation on a FreeBSD-7 system.
http://docs.python.org/dev/library/socket.html#example
dhcppc1# cat server.py
# Echo server program
import socket
import sys
HOST = '' # Symbolic name meaning the local host
PORT = 50007 # Arbitrary non-privileged port
s = None
for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.bind(sa)
s.listen(1)
except socket.error, msg:
s.close()
s = None
continue
break
if s is None:
print 'could not open socket'
sys.exit(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data: break
conn.send(data)
conn.close()
dhcppc1#
dhcppc1# uname -a
FreeBSD dhcppc1# 7.0-RC1 FreeBSD 7.0-RC1 #0 Mon Dec 24 12:18:24 UTC 2007
root at logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC o386
dhcppc1#
dhcppc1# python2.5 server.py
Traceback (most recent call last):
File "server.py", line 8 in <module>
for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
socket.gaierror: (8, 'hostname nor servname provided, or not known')
dhcppc1#
----------
assignee: georg.brandl
components: Documentation
messages: 66244
nosy: georg.brandl, giampaolo.rodola
severity: normal
status: open
title: A socket example code shown in doc doesn't work on FreeBSD
versions: Python 2.6
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2763>
__________________________________
More information about the New-bugs-announce
mailing list