On Dec 22, 2:49 am, Chris <chris8b...@gmail.com> wrote:
> Hello,
>
> I have a client that needs to constantly send data to Django-based
> backend. The client code follows the pattern:
>
> ...
> s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
> s.connect( ( '10.20.30.40',  8080 ) )
> while True :
>     data = s.recv( 2048 )
>     print data
>
>     s.send( r'something' )
> ...
>
> Could you advice on possible approaches to come up with a Django
> implementation of a backend that can work with such client, please?

Hello,

Since django is a web framework,   the requests that it can handle
need to be http-based.  I don't think  that a django view can listen
directly on a TCP socket   (the web server is doing the listening ,
not the django itself  )  .

However,  i'm sure that there are workarounds possible. It all depends
on what are your specific needs :
- if you are now writing the client from scratch,  you can wrap the
binary
data in a XML-RPC request. And you can write a  django view to handle
the XML-RPC request.   If you are free to choose the data format you
can send the data as dictionaries/hashes  (much easier to handle than
parsing binary data ).

- if the TCP client is an already existing program that can't be
changed,
you can write a python program that listens on a TCP port  and then
forwards the data to the django application using XML-RPC .

I'm mentioning XML-RPC because i've used it lately and i'm somewhat
accustomed to it.   Perhaps other can suggest more solutions that
you could try.



Cheers,
Adrian

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.


Reply via email to