On Tue, Dec 27, 2011 at 5:41 AM, Vovk Donets <donets.vladimir@gmail.com> wrote:
To accepts socket connetction you need always listen some port. Othewise you will be trying hit a bulls eye when sending data to this port (if you would listen port only when view was called) View is a function it's not a webserver that runs and listen to port.
You need to decouple working with sockets from view and place it somewere outside django2011/12/27 Vovk Donets <donets.vladimir@gmail.com>
For what you need this?
Maybe you should consider using Celery for doing background jobs.--2011/12/23 Kay <fcapba1220@gmail.com>
if I have easy asyncore socket code as follow:
--------------------------------------------------------------------------------------------------------------
import socket
import asyncore
class asysocket(asyncore.dispatcher):
def __init__(self,host,port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((host, port))
self.listen(10)
print 'server is waiting for socket connection...'
def handle_accept(self):
new,addr = self.accept()
print 'received from address', addr
data = new.recv(1024)
print repr(data)
def handle_close(self):
self.close()
server = asysocket('127.0.0.1',1234)
asyncore.loop()
----------------------------------------------------------------------------------------------------------------
then how to use this in my django project views.py to let it
automatically work for receiving connection
while i start the project as "python manage.py runserver [port]"??
thanks
Vovk Donets
python developer
--
Vovk Donets
python developer
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
Joseph Slone
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment