Kurt,

I am new to socket programming.  I will review and get back to you.

Thanks,
Ed

On 8/11/2017 5:19 PM, Kurt Van Dijck wrote:
    I am trying to allow a second application to send a STOP command to
    MPD, using the existing local socket created by MPD.  I would like to
    allow a form of Convenience Switching.  So if music is playing through
    MPD from an MPD client (JRiver).  The second application could then
    STOP MPD play safely(as though command came from MPD client (Jriver).
    I have attached a terminal screen shot  below, showing mpd socket
    assignment.

A snippet I wrote recently:

static int connect_uri(const char *host, int port, int preferred_type)
{
        int sock;

        if (*host == '@' || *host == '/') {
                /* unix socket */
                struct sockaddr_un addr = {
                        .sun_family = AF_UNIX,
                };
                int socklen;

                strcpy(addr.sun_path, host);
                socklen = strlen(host) + offsetof(struct sockaddr_un, sun_path);

                sock = socket(AF_UNIX, preferred_type, 0);
                if (sock < 0)
                        mylog(LOG_ERR, "socket AF_UNIX ...: %s", ESTR(errno));
                if (connect(sock, (void *)&addr, socklen) < 0)
                        mylog(LOG_ERR, "bind %s: %s", host, ESTR(errno));
                return sock;
        }

The remainder goes via ip sockets, which is not necessarily what you
want.

Is this what you were looking for?

Kurt




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to