Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Communication between C++ server and Python app

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


marcin.maksymiuk at googlemail

Apr 28, 2012, 5:45 PM

Post #1 of 14 (1463 views)
Permalink
Communication between C++ server and Python app

Hi,

I've got a server process written in C++ running on Unix machine.
On the same box I'd like to run multiple Python scripts that will
communicate with this server.

Can you please suggest what would be best was to achieve this ?

Kind regards and thanks in advance!
M.
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Apr 28, 2012, 6:42 PM

Post #2 of 14 (1418 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

On Sun, Apr 29, 2012 at 10:45 AM, kenk <marcin.maksymiuk [at] googlemail> wrote:
> Hi,
>
> I've got a server process written in C++ running on Unix machine.
> On the same box I'd like to run multiple Python scripts that will
> communicate with this server.
>
> Can you please suggest what would be best was to achieve this ?

Personally, I would recommend a TCP socket, because that allows the
flexibility of splitting across multiple computers. But for
efficiency, you may want to consider a Unix socket too.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Apr 28, 2012, 7:05 PM

Post #3 of 14 (1414 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

In article
<108cb846-6bb9-4600-a984-2fded0c919bd [at] er9g2000vbb>,
kenk <marcin.maksymiuk [at] googlemail> wrote:

> Hi,
>
> I've got a server process written in C++ running on Unix machine.
> On the same box I'd like to run multiple Python scripts that will
> communicate with this server.
>
> Can you please suggest what would be best was to achieve this ?

There are so many reasonable answers, it's hard to know where to start.
Perhaps if you could give us some clue as to what the server does, it
might help.

What kind of data are you passing back and forth? Text? Binary? Is it
important that the communication be as efficient as possible, or is it
more important that the code be easy to write? Are you worried about
security? Will you ever need to interoperate with other systems written
in other languages?
--
http://mail.python.org/mailman/listinfo/python-list


rodrick.brown at gmail

Apr 28, 2012, 9:00 PM

Post #4 of 14 (1419 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

What interfaces are available on the server process?

Sent from my iPad

On Apr 28, 2012, at 8:45 PM, kenk <marcin.maksymiuk [at] googlemail> wrote:

> Hi,
>
> I've got a server process written in C++ running on Unix machine.
> On the same box I'd like to run multiple Python scripts that will
> communicate with this server.
>
> Can you please suggest what would be best was to achieve this ?
>
> Kind regards and thanks in advance!
> M.
> --
> http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


cs at zip

Apr 28, 2012, 11:24 PM

Post #5 of 14 (1417 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

On 29Apr2012 11:42, Chris Angelico <rosuav [at] gmail> wrote:
| On Sun, Apr 29, 2012 at 10:45 AM, kenk <marcin.maksymiuk [at] googlemail> wrote:
| > I've got a server process written in C++ running on Unix machine.
| > On the same box I'd like to run multiple Python scripts that will
| > communicate with this server.
| >
| > Can you please suggest what would be best was to achieve this ?
|
| Personally, I would recommend a TCP socket, because that allows the
| flexibility of splitting across multiple computers.

And the pain of ensuring security, if you're in an open network.

| But for
| efficiency, you may want to consider a Unix socket too.

A UNIX socket or even a named pipe has the benefit of:
- not being available remotely
- access control with normal UNIX permissions
and of course efficiency as you say.

Generalising to a TCP socket later shouldn't be too hard if the need
arises.

Cheers,
--
Cameron Simpson <cs [at] zip> DoD#743
http://www.cskk.ezoshosting.com/cs/

Waiting for the bus is a bad idea if you turn out to be the bus driver.
- Michael M. Butler on the Singularity
--
http://mail.python.org/mailman/listinfo/python-list


th982a at googlemail

Apr 29, 2012, 4:00 AM

Post #6 of 14 (1414 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

Take the twisted library.
I used to write myself a socket server and client.

Socket is fast, but you need on the other hand to know how big the
dataset might be, that will be serialized and deserialized as well.



Tamer

Am 29.04.2012 08:24, schrieb Cameron Simpson:
> On 29Apr2012 11:42, Chris Angelico <rosuav [at] gmail> wrote:
> | On Sun, Apr 29, 2012 at 10:45 AM, kenk <marcin.maksymiuk [at] googlemail> wrote:
> | > I've got a server process written in C++ running on Unix machine.
> | > On the same box I'd like to run multiple Python scripts that will
> | > communicate with this server.
> | >
> | > Can you please suggest what would be best was to achieve this ?
> |
> | Personally, I would recommend a TCP socket, because that allows the
> | flexibility of splitting across multiple computers.
>
> And the pain of ensuring security, if you're in an open network.
>
> | But for
> | efficiency, you may want to consider a Unix socket too.
>
> A UNIX socket or even a named pipe has the benefit of:
> - not being available remotely
> - access control with normal UNIX permissions
> and of course efficiency as you say.
>
> Generalising to a TCP socket later shouldn't be too hard if the need
> arises.
>
> Cheers,

--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Apr 29, 2012, 4:08 AM

Post #7 of 14 (1417 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson <cs [at] zip> wrote:
> On 29Apr2012 11:42, Chris Angelico <rosuav [at] gmail> wrote:
> | Personally, I would recommend a TCP socket, because that allows the
> | flexibility of splitting across multiple computers.
>
> And the pain of ensuring security, if you're in an open network.

You have that with all IPC. You can always bind to 127.0.0.1 or ::1 to
stop other hosts from connecting; and then it's minimal change to open
it up.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


marcin.maksymiuk at googlemail

Apr 29, 2012, 2:34 PM

Post #8 of 14 (1424 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

Failr point - I should do that in original question.

The C++ server runs on Unix (Mac OS X as a matter of fact) and, as I'm the one who develops it, can use whthever technology is suitable.
Currently it uses STL, Boost and Qt libraries.

The server is responsible for providing connectivity to stock exchange and will be used mainly to monitor price of certain financial instruments and placing/cancelling orders.
My idea is to keep this as simple tool that will execute whathever it's asked for.

On top of this server I plan to write some trading logic in Python - scripts that will trigger certain actions depending on situation on market.

I planned to exchange text commands between the C++ server and Python scripts as Python is really good in parsing text and on server side Boost/STL also do the trick.
Communication between 'logic' and the server won't be high frequency - I plan to talk to teh server ~10 times a minute.

Will appreciate suggestions.

M.



On 29 Apr 2012, at 05:00, Rodrick Brown wrote:
>
> Sent from my iPad
>
> On Apr 28, 2012, at 8:45 PM, kenk <marcin.maksymiuk [at] googlemail> wrote:
>
>> Hi,
>>
>> I've got a server process written in C++ running on Unix machine.
>> On the same box I'd like to run multiple Python scripts that will
>> communicate with this server.
>>
>> Can you please suggest what would be best was to achieve this ?
>>
>> Kind regards and thanks in advance!
>> M.
>> --
>> http://mail.python.org/mailman/listinfo/python-list


cs at zip

Apr 29, 2012, 4:18 PM

Post #9 of 14 (1409 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

On 29Apr2012 21:08, Chris Angelico <rosuav [at] gmail> wrote:
| On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson <cs [at] zip> wrote:
| > On 29Apr2012 11:42, Chris Angelico <rosuav [at] gmail> wrote:
| > | Personally, I would recommend a TCP socket, because that allows the
| > | flexibility of splitting across multiple computers.
| >
| > And the pain of ensuring security, if you're in an open network.
|
| You have that with all IPC. You can always bind to 127.0.0.1 or ::1 to
| stop other hosts from connecting; and then it's minimal change to open
| it up.

I'm as concerned with other users as with other hosts. Hence the pleasures of
UNIX permissions on a socket. You're right, I did say "open network", didn't
I? Nonetheless, my preference stands unless a new use case arises.

Cheers,
--
Cameron Simpson <cs [at] zip> DoD#743
http://www.cskk.ezoshosting.com/cs/

Just because Unix is a multiuser system doesn't mean I want to share it with
anybody! - Paul Tomblin, in rec.aviation.military
--
http://mail.python.org/mailman/listinfo/python-list


marcin.maksymiuk at googlemail

Apr 30, 2012, 12:56 PM

Post #10 of 14 (1411 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

Failr point - I should do that in original question.

The C++ server runs on Unix (Mac OS X as a matter of fact) and, as I'm
the one who develops it, can use whthever technology is suitable.
Currently it uses STL, Boost and Qt libraries.

The server is responsible for providing connectivity to stock exchange
and will be used mainly to monitor price of certain financial
instruments and placing/cancelling orders.
My idea is to keep this as simple tool that will execute whathever
it's asked for.

On top of this server I plan to write some trading logic in Python -
scripts that will trigger certain actions depending on situation on
market.

I planned to exchange text commands between the C++ server and Python
scripts as Python is really good in parsing text and on server side
Boost/STL also do the trick.
Communication between 'logic' and the server won't be high frequency -
I plan to talk to teh server ~10 times a minute.

Will appreciate suggestions.

M.
--
http://mail.python.org/mailman/listinfo/python-list


miki.tebeka at gmail

Apr 30, 2012, 2:03 PM

Post #11 of 14 (1433 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

> > I've got a server process written in C++ running on Unix machine.
> > On the same box I'd like to run multiple Python scripts that will
> > communicate with this server.
> >
> > Can you please suggest what would be best was to achieve this ?
As said before, there are many options. Here are some:
* protobuf, thrift, avro ...
* json/xml over http
- Python has XMLRPC module
* zeromq
* ...

IMO investigate some time learning the options, code a simple api using one or two that you like and pick a winner.

For 10 calls/min you can go that wrong either way :)
--
http://mail.python.org/mailman/listinfo/python-list


awilliam at whitemice

May 1, 2012, 7:47 AM

Post #12 of 14 (1397 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

On Sat, 2012-04-28 at 17:45 -0700, kenk wrote:
> I've got a server process written in C++ running on Unix machine.
> On the same box I'd like to run multiple Python scripts that will
> communicate with this server.
> Can you please suggest what would be best was to achieve this ?

Time to start using a message broker that can also grow to other
applications.

RabbitMQ. Simple, fast, and easy to manage.
<http://www.rabbitmq.com/>

This allows each service to have outages without loosing information.
Attachments: signature.asc (0.19 KB)


jeanmichel at sequans

May 9, 2012, 5:47 AM

Post #13 of 14 (1371 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

kenk wrote:
> Hi,
>
> I've got a server process written in C++ running on Unix machine.
> On the same box I'd like to run multiple Python scripts that will
> communicate with this server.
>
> Can you please suggest what would be best was to achieve this ?
>
> Kind regards and thanks in advance!
> M.
>
xmlrpc shoudl do it.

http://en.wikipedia.org/wiki/XML-RPC

There's is a client/server python module fort that, same for C++. Your
python client will be able to call C++ server procedures.

It could be slighlty overkill but that get rid of the tedious socket
programming.

JM
--
http://mail.python.org/mailman/listinfo/python-list


premiumtelco.com at gmail

Mar 23, 2013, 3:07 AM

Post #14 of 14 (802 views)
Permalink
Re: Communication between C++ server and Python app [In reply to]

I normally wouldn’t be able to find such great content as this on other
sites. You have done a great job with each unique point made on this topic.
Thank you for your hard work.





-----
premium rate numbers
Click Here
premiumtelco
--
View this message in context: http://python.6.n6.nabble.com/Communication-between-C-server-and-Python-app-tp4937660p5011431.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.