Question

I have a server-program which processes audio-data and passes it thru to the audio-drivers.

The server-program copies the audio-data and puts the copy in a named FIFO in a seconds thread.

If there is no client reading on the other side of the FIFO it does not matter, because it just blocks the FIFO-thread.

Now I would like to add a "control"-functionality like "increase volume, play faster etc." so the eventually connected client can control the server-program.

The important thing is: If the client eventually disconnects (through close() or abort) the server has detect this and should fall back into normal mode and forget all the commands from the client.

I have never used sockets until now, so I'm not sure what's the best way:

  1. use the FIFO from server->client as it is and add a socket just for client->server communication?

  2. use one socket to stream server->client and give commands from client->server (in byte-format?)

I would use "AF_UNIX, SOCK_STREAM" for the socket. Is #2 the better variant? And how can I determine if the client disconnected without a close()?

Was it helpful?

Solution

i vote option nr.2 and a possible solution for that is:

1-create socket[sock_stream....];

2-fork()[inherits the socket descriptor];

-father[use to read];
-son[use to write];

you can implement to detect a client disconnection when read() from socket descriptor returns 0bytes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top