:: [DNG] Unix Socket class: how to sen…
Kezdőlap
Delete this message
Reply to this message
Szerző: aitor_czr
Dátum:  
Címzett: dng
Tárgy: [DNG] Unix Socket class: how to send arguments to the suid of simple-netaid
Hi all,

Here you are an example of the unix socket class used in simple-netaid
for sending the arguments
to the suid binary through a file descriptor instead of using arguments
in the command line:

http://gnuinos.org/socket/socket-class-example/

You'll need to install libglibmm-2.4-dev for the server of the socket
(It's multithreaded and uses a
Glib::Threads::Thread *thread pointer).

As you can see in the example (have a look at the main.cpp of the
server), the constructor of the
serverSocket class receives the name of the file descriptor as a first
argument:

serverSocket sender( FILE_DESCRIPTOR, std::string... );

The rest of the arguments in the constructor are the values of the
arguments sent by the socket,
and both the quantity and the length of these strings are unlimited. The
client side of the socket
class will use a std::vector<std::string> for the received
arguments(look at the main.cpp of the
server).

After building the example (use the Makefile for that), just run the
server in a secondary plane:

$ ./server &
[1] 10739

It may then run the client, getting all the received mesages:

$ ./client
These are the received messages:
    0
    Hi
    hello
    folks
[1]+  Hecho                   ./server

You can download the tarball of the example from here:

wget http://gnuinos.org/socket/socket_class_example.tar.gz

Cheers,

Aitor.