Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Simple IPC using Sockets
Simple IPC using Sockets [message #25224] Mon, 15 February 2010 00:36 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hello All,

I would like to share one very small class I wrote. It is simple object providing mostly automatic and very easy to set up interprocess communication. Example of usage is attached as well.

Basic goals:
  • Simple to use
  • No specialized server app required
  • Everything should be as automatic as possible
  • Programmer can simply define communication protocol
  • Communication is done via Sockets, no shared memory (related to the next point)
  • It is not meant to be robust, but to allow easy and rapid development for small scale apps.

Implemented features:
  • Everything mentioned in goals (I hope Smile )
  • Protocol is specified using Callbacks, so rules can have different forms (e.g: single function with switch for handling messages OR several functions, each is defining one rule (used in example app) OR even pipeline style processing, where each function modifies the output of previous function and then passes it to next)
  • One instance of application performs the tasks of server in separate thread. This role is automatically picked up by another instance when the previous server is closed.
  • Optionally, programmer can start/stop server thread.


Warning: This package was not extensively tested yet, you might experience all sort of bad things from loss of information to deadlocks. It did not happen to me, but it doesn't mean it can't happen Smile There is a high probability that I will develop this code further in future, since I wan't to use it in one of my projects.

About the example app: It's a console app that does nothing else then manages a list of strings (Vector<String> internally) from a simple shell. You can display it's content (command "show"), add ("add something") and delete items ("del number"). To exit, type "quit". Nothing much, heh? Smile The interesting part is that if you open few more instances of this application, they will all behave as if they worked with single variable (but they of course do not, they just keep their own variable in sync). And this magic is done in ~50 lines of code, out of which is ~4O lines are definitions of protocol.

If you think this is interesting/useful please let me know. Suggestions for further development are welcomed too Wink


Best regards,
Honza
  • Attachment: IPC.zip
    (Size: 3.22KB, Downloaded 487 times)

[Updated on: Mon, 15 February 2010 01:43]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon9.gif
Read Message
Read Message
Previous Topic: Fix for examples/CodeMetric
Next Topic: Compiling MPIR in TheIde
Goto Forum:
  


Current Time: Fri Mar 29 02:24:16 CET 2024

Total time taken to generate the page: 0.01077 seconds