2016-05-30 16:30:05 +02:00
|
|
|
#!/bin/dash
|
|
|
|
|
|
|
|
REP=/tmp/ipc/
|
2016-06-05 20:48:13 +02:00
|
|
|
SERVICE="pongd"
|
2016-09-10 18:34:02 +02:00
|
|
|
NB=10
|
2016-05-30 16:30:05 +02:00
|
|
|
# CLEAN UP !
|
|
|
|
if [ $# -ne 0 ] && [ "$1" = clean ]
|
|
|
|
then
|
|
|
|
echo "clean rep ${REP}"
|
2016-09-15 15:34:56 +02:00
|
|
|
rm ${REP}/${SERVICE} 2>/dev/null
|
|
|
|
rm ${REP}/*-in 2>/dev/null
|
|
|
|
rm ${REP}/*-out 2>/dev/null
|
2016-05-30 16:30:05 +02:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ne 0 ]
|
|
|
|
then
|
|
|
|
NB=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
for pid in `seq 1 ${NB}`
|
|
|
|
do
|
|
|
|
# we make the application pipes
|
2016-10-27 16:27:04 +02:00
|
|
|
# mkfifo ${REP}${pid}-1-1-in 2>/dev/null
|
|
|
|
# mkfifo ${REP}${pid}-1-1-out 2>/dev/null
|
2016-05-30 16:30:05 +02:00
|
|
|
|
|
|
|
# pid index version
|
2016-10-27 16:27:04 +02:00
|
|
|
echo "${pid} 1 1" | nc -U ${REP}${SERVICE}
|
|
|
|
|
2016-05-30 16:30:05 +02:00
|
|
|
# the purpose is to send something in the pipe
|
2016-10-27 16:27:04 +02:00
|
|
|
#cat /dev/urandom | base64 | head -n 1 > ${REP}${pid}-1-1-out
|
2016-10-28 13:58:04 +02:00
|
|
|
echo "hello frero" | nc -U ${REP}${pid}-1-1
|
2016-10-27 16:27:04 +02:00
|
|
|
#echo "exit" | nc -U ${REP}${pid}-1-1
|
2016-05-30 16:30:05 +02:00
|
|
|
|
2016-10-27 16:27:04 +02:00
|
|
|
# the service will answer with our message
|
2016-09-10 18:34:02 +02:00
|
|
|
echo "pid : ${pid}"
|
2016-10-27 16:27:04 +02:00
|
|
|
#cat ${REP}/${pid}-1-1-in
|
2016-09-18 00:15:14 +02:00
|
|
|
|
2016-05-30 16:30:05 +02:00
|
|
|
done
|
2016-09-10 18:34:02 +02:00
|
|
|
|
2016-10-27 16:27:04 +02:00
|
|
|
echo "exit" | nc -U ${REP}${SERVICE}
|
|
|
|
|
2016-09-17 14:49:10 +02:00
|
|
|
echo "clean rep"
|
2016-10-27 16:27:04 +02:00
|
|
|
#rm ${REP}/*
|
|
|
|
#rm ${REP}/*-out
|