mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-14 22:51:13 +02:00
2018-12-04 Fred Gleason <fredg@paravelsystems.com>
* Added an rdrlmd(8) service. * Implemented JSON-formatted PAD output on TCP port 34289.
This commit is contained in:
58
lib/rdunixsocket.cpp
Normal file
58
lib/rdunixsocket.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// rdunixsocket.cpp
|
||||
//
|
||||
// UNIX Socket
|
||||
//
|
||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <linux/un.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "rdunixsocket.h"
|
||||
|
||||
RDUnixSocket::RDUnixSocket(QObject *parent)
|
||||
: QTcpSocket(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool RDUnixSocket::connectToPathname(const QString &pathname,
|
||||
QAbstractSocket::OpenMode mode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool RDUnixSocket::connectToAbstract(const QString &addr,
|
||||
QAbstractSocket::OpenMode mode)
|
||||
{
|
||||
int sock;
|
||||
struct sockaddr_un sa;
|
||||
|
||||
if((sock=::socket(AF_UNIX,SOCK_STREAM,0))<0) {
|
||||
return false;
|
||||
}
|
||||
memset(&sa,0,sizeof(sa));
|
||||
sa.sun_family=AF_UNIX;
|
||||
strncpy(sa.sun_path+1,addr.toUtf8(),UNIX_PATH_MAX-1);
|
||||
if(::connect(sock,(struct sockaddr *)(&sa),sizeof(sa))<0) {
|
||||
return false;
|
||||
}
|
||||
setSocketDescriptor(sock,QAbstractSocket::ConnectedState,mode);
|
||||
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user