GithubHelp home page GithubHelp logo
The Goal of this Project is to demonstrate that I can pass information from one process (executable/program) to another.
I need to pass 24 bytes of data from one program (or process) to another.

Previously I created a simple shared memory project that demonstrates exchanging data (as described above) using mmaps()
or Shared Memory Mapping. This works and seems like it will be very fast; however, in conversation with my friend Peter
he recommended that I look into Unix Domain Sockets (UDS) instead of using Shared Memory Mapping. His reasoning was:

        1.  Sharing Memory between processes is generally 'dangerous' and software developers typically try and avoid
            doing this when possible. From my understanding it is considered 'dangerous' because you have to handle
            memory synchronization and its actually not to hard to find yourself in a situation where you can
            accidentally cause undefined behavior (if you go over the amount of data in your page, etc)

        2.  UDS is more similar to inter-computer communication and it will be easier to switch to that in the future

I was surprised how few examples in this use case I could find. I had to do a lot of digging. I ended up finding the man
pages the most useful. Here's the one that got me there: https://man7.org/linux/man-pages/man7/unix.7.html

I did my best to add in comments so I could come back to this at a later date and still understand whats going on...

The general process happening is:
Server creates a file descriptor (FD) and an sockaddr(I'm equating this to an address is some remote virtual fairly land)
we then bind the socket to the sockaddr. Once bound, we can start listening for/accepting connections with clients.
On the client side. We create an FD and bind it to the same sockaddr Path we set up the server with. This creates the link.
The client can then request a connection from the server. When the server accepts the connection it sends the file descriptor
location to the output of the connect() function the client called. This is the FD the server and client will pass data on.
The first FD was just so the server can listen for clients.



Here are some Key words That I used to get to this program running:

Inter Process Communication
Unix Domain Sockets (UDS)
Remote Process Communication
poll()
read()
recv()
write()
send()
sendto()

Kyle Park's Projects

kortex icon kortex

Code examples and API documentation for KINOVA® KORTEX™ robotic arms

unixdomainsocketsexample icon unixdomainsocketsexample

A simple program that creates an inter-process communication pipe over a Unix Domain Socket set up with SOCK_SEQPACKET

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.