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 django
2011/12/27 Vovk Donets <donets.vladi...@gmail.com> > For what you need this? > Maybe you should consider using Celery for doing background jobs. > > > 2011/12/23 Kay <fcapba1...@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 > > skype: suunbeeam > icq: 232490857 > mail: donets.vladi...@gmail.com > www: jetfix.ru > > -- *Vovk Donets* python developer skype: suunbeeam icq: 232490857 mail: donets.vladi...@gmail.com www: jetfix.ru -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.