PDA

View Full Version : Socket & bind


tbje
2005-06-22, 18:05
hi, i get an socket.error 10049 - "can't assign requested address" when trying to bind a socket on the xbox:

udpsock = socket(af_inet,sock_dgram)
udpsock.bind((gethostbyname(gethostname()), htons(port)))

i've tried some a great number of values for port (80, 280, 2800, 7000) but i allways get the same error.
have also tried removing the htons without any luck?

is it possible to create a server with xbmc python?

khermans
2007-04-29, 19:46
IS THIS FIXED YET? I have same issue :-(

This simple code fails...save as default.py and try to run as XBMC script

#create an INET, STREAMing socket
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#bind the socket to a public host,
# and a well-known port
serversocket.bind((socket.gethostname(), 80))
#become a server socket
serversocket.listen(5)

elupus
2007-04-29, 21:21
binding to port 80 should always fail as that is used for http.. but i'm guessing you've tried other ports?

khermans
2007-04-30, 07:05
binding to port 80 should always fail as that is used for http.. but i'm guessing you've tried other ports?

Yes, I have tried 0, 53114, and other ports. Still no good. Although, I was able to bypass the bind using '' as the IP/host, but I think it really failed without throwing an exception...

elupus
2007-04-30, 12:35
was just going to post that you MUST use "" for ip/host :). xbox ip stack doesn't allow anything else. can add a check for it so that it defults to "" when it detects a local address.

elupus
2007-05-05, 19:14
this has been fixed in svn now.