The best solution is make two different projects
one is your socket server and the other is the Django project.
is not a good idea connect with socket directly to Django, this will be cause some large delays and in case of connection fails?
what is the timeout of the socket connection?
is the same of dingo app?
The solutions will be, for example
django
celery
socket server
django is independently and the models are updated from celery workers
this is the link of celery, is not so much easy but you can send some emails in this group and i'm sure that someone is ready to help you
have a nice day
El 27/05/2013, a las 14:14, chiara@tecnoelettricabrianza.it escribió:
Hi there, I'm a really newbye, I've followed the polls tutorial.I'm looking for a way to dinamically create web-pages that will send and receive message to a TCP/Ip server that use a custom protocol for communication.I've got the python code that handle the communication and I kindly ask you some advice on the right way to do it:1)create a model with the fields of data to be sent and received from server2)create in the view: 1) function that handle the connection2) function that send data3) function that receive data3) create a template with model's fieldsIs this right?Below the python code that is now standalone and working to connect to server.#Socket client in pythonimport socket #for socketsimport sys #for exit#create an INET, STREAMing sockettry:s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)except socket.error:print 'Failed to create socket'sys.exit()print 'Socket Created'host = '192.168.1.1';port = 35000;try:remote_ip = socket.gethostbyname( host )except socket.gaierror:#could not resolveprint 'Hostname could not be resolved. Exiting'sys.exit()#Connect to remote servers.connect((remote_ip , port))print 'Socket Connected to ' + host + ' on ip ' + remote_ip## SEND DATAmessage = "GET / HTTP/1.1\r\n\r\n"try :#Set the whole strings.sendall(message)except socket.error:#Send failedprint 'Send failed'sys.exit()print 'Message send successfully'#RECEIVE DATAreply = s.recv(4096)print replys.close()Please let me know about it. Thanks. BR.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment