pombreda / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
0 stars 0 forks source link

multi-thread server function #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have a driver-like socket interface function, meaning 
that it would be easily usable over networks and different programming 
languages.

It would use a command-type interface. Example:

<python>

import socket
com = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
com.bind(('localhost', 98712))
com.connect()
com.send('find_brick') #connect to brick command, this would cause the 
driver to do x = find_one_brick()
rslt = com.recv(1) #get return code
if rslt != 0:
   print 'no brick found.'
   exit(1)
com.send('get_light_sample') #would trigger a get_sample() routine
dist = com.recv(10)
print dist
com.send('close_brick_sock') #would trigger brick's close() command
com.close()

</python>

There would be many commands, including 'kill_server', to be called when 
the server has done its job.

To start the server, one would use, in a separate program:

<python>

import nxt.server
nxt.server.serve_forever()

</python>

I'll see what I can do to get started on this, it might take a while 
because of socket and thread things. However, a single-thread server will 
robably be relatively easy.

Original issue reported on code.google.com by marcus@wanners.net on 4 Feb 2009 at 6:21

GoogleCodeExporter commented 9 years ago

Original comment by marcus@wanners.net on 4 Feb 2009 at 6:22

GoogleCodeExporter commented 9 years ago
I think I'll use datagram sockets. It would be much simpler for both the server 
and 
the client, however there is a chance that messages will get lost (it is 
relatively 
slim, though). I'm working on it now.

Original comment by marcus@wanners.net on 19 Mar 2009 at 6:32

GoogleCodeExporter commented 9 years ago

Original comment by marcus@wanners.net on 20 Mar 2009 at 4:31

GoogleCodeExporter commented 9 years ago

Original comment by marcus@wanners.net on 20 Aug 2010 at 1:59

GoogleCodeExporter commented 9 years ago

Original comment by marcus@wanners.net on 6 Feb 2011 at 1:04

GoogleCodeExporter commented 9 years ago
We've now implemented something like this in the trunk. Enjoy!

Original comment by Zonedab...@gmail.com on 10 May 2011 at 2:28