dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

problems setting up socket communication

Wed Jun 12, 2013 8:33 pm

hi,

I am quite new to raspberry so I am probably making a beginner mistake here. I am trying to send a message from a html page to my raspberry and following this tutorial:

http://niltoid.com/blog/raspberry-pi-arduino-tornado/

My problem is already in the first part. I installed everything as requested but python pythonserver.py returns an error:

[email protected] ~/Desktop/Python $ python pythonserver.py
Traceback (most recent call last):
File "pythonserver.py", line 13, in <module>
application.listen(8080,"0,0,0,0")
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1343, in listen
server.listen(port, address)
File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 113, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 67, in bind_sockets
0, flags)):
socket.gaierror: [Errno -2] Name or service not known


I see the error showing up on google a couple of times but I don't think the solutions match my problem and are quite complex. Anybody that can help?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4248
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: problems setting up socket communication

Wed Jun 12, 2013 8:42 pm

File "pythonserver.py", line 13, in <module>
application.listen(8080,"0,0,0,0")
That is not what the tutorial says.

Code: Select all

if __name__ == "__main__":
    application.listen(8080)
    tornado.ioloop.IOLoop.instance().start()
Did you add the "0,0,0,0"? It isn't a valid IP address, and I doubt it is anything that tornado will understand. What are you trying to do by putting it in?

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: problems setting up socket communication

Wed Jun 12, 2013 8:53 pm

This line was in the comments on the tutorial page. When i do not add it I get the following error:

Traceback (most recent call last):
File "/home/pi/Desktop/Python/pythonserver.py", line 13, in <module>
application.listen(8080)
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1343, in listen
server.listen(port, address)
File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 113, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 69, in bind_sockets
sock = socket.socket(af, socktype, proto)
File "/usr/lib/python2.7/socket.py", line 187, in __init__
_sock = _realsocket(family, type, proto)
socket.error: [Errno 97] Address family not supported by protocol

The error is gone when I replace the line

timhoffman
Posts: 85
Joined: Sat Nov 05, 2011 11:31 pm

Re: problems setting up socket communication

Thu Jun 13, 2013 11:31 am

Actually 0.0.0.0 is perfectly valid. It means listen on all IPv4 interfaces.
Though it may not be valid with tornado for some reason.

Given your starting out, any particular reason you chose tornado rather than just using HTTPServer (I know in the long run you wouldn't use it.) You might find it as easier starting point here is simple tutorial http://www.codeproject.com/Articles/462 ... -in-Python

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: problems setting up socket communication

Thu Jun 13, 2013 2:22 pm

Thank you for you replies!

The tutorial I was following seemed pretty straight forward and understandable for me (except from the problem I am running into). The link you send looks more complex than what I started initially. Do you not have an idea what I could have done wrong?

DrMag
Posts: 63
Joined: Sat Jun 01, 2013 7:59 pm

Re: problems setting up socket communication

Thu Jun 13, 2013 5:39 pm

Just a thought, as I'm not familiar with the libraries or tutorial you're using: you listed the IP address delimited by commas; should it be with periods instead?

0.0.0.0 instead of 0,0,0,0

dqpi
Posts: 33
Joined: Fri May 24, 2013 12:22 pm

Re: problems setting up socket communication

Thu Jun 13, 2013 10:06 pm

That worked. Thank you for the solution.

Return to “Python”