• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

Public Types | Public Member Functions | Protected Slots | List of all members
KLocalSocket Class Reference

#include <klocalsocket.h>

Inheritance diagram for KLocalSocket:
Inheritance graph
[legend]

Public Types

enum  LocalSocketType { UnixSocket, AbstractUnixSocket, UnknownLocalSocketType = -1 }
 

Public Member Functions

 KLocalSocket (QObject *parent=0)
 
virtual ~KLocalSocket ()
 
void connectToPath (const QString &path, OpenMode mode=ReadWrite)
 
void connectToPath (const QString &path, LocalSocketType type, OpenMode mode=ReadWrite)
 
void disconnectFromPath ()
 
QString localPath () const
 
LocalSocketType localSocketType () const
 
QString peerPath () const
 

Protected Slots

void connectToHostImplementation (const QString &hostName, quint16 port, OpenMode mode)
 
void disconnectFromHostImplementation ()
 

Detailed Description

KLocalSocket allows one to create and use local (Unix) sockets.

On some platforms, local sockets are a kind of streaming socket that can be used to transmit and receive data just like Internet (TCP) streaming sockets. The difference is that they remain local to the host running them and cannot be accessed externally. They are also very fast and (in theory) consume less resources than standard TCP sockets.

KLocalSocket supports two kinds of local socket types (see KLocalSocket::LocalSocketType):

  • Unix sockets (UnixSocket): standard Unix sockets whose names are file paths and obey filesystem restrictions
  • Abstract Unix sockets (AbstractUnixSocket): similar to Unix sockets, but they don't exist as entries in the filesystem and, thus, aren't restricted by its permissions
Author
Thiago Macieira thiag.nosp@m.o@kd.nosp@m.e.org

Definition at line 51 of file klocalsocket.h.

Member Enumeration Documentation

enum KLocalSocket::LocalSocketType

Defines the local socket type.

See KLocalSocket for more information

Enumerator
UnixSocket 

Unix sockets.

AbstractUnixSocket 

Abstract Unix sockets.

UnknownLocalSocketType 

Definition at line 59 of file klocalsocket.h.

Constructor & Destructor Documentation

KLocalSocket::KLocalSocket ( QObject *  parent = 0)
explicit

Creates a KLocalSocket object with parent as the parent object.

Parameters
parentthe parent object

Definition at line 44 of file klocalsocket.cpp.

KLocalSocket::~KLocalSocket ( )
virtual

Destroys the KLocalSocket object and frees up any resources associated.

If the socket is open, it will be closed.

Definition at line 49 of file klocalsocket.cpp.

Member Function Documentation

void KLocalSocket::connectToHostImplementation ( const QString &  hostName,
quint16  port,
OpenMode  mode 
)
protectedslot

Definition at line 67 of file klocalsocket.cpp.

void KLocalSocket::connectToPath ( const QString &  path,
OpenMode  mode = ReadWrite 
)

Opens a connection to a listening Unix socket at path.

Use waitForConnection() to find out if the connection succeeded or not.

Parameters
paththe Unix socket to connect to
modethe mode to use when opening (see QIODevice::OpenMode)

Definition at line 55 of file klocalsocket.cpp.

void KLocalSocket::connectToPath ( const QString &  path,
LocalSocketType  type,
OpenMode  mode = ReadWrite 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Opens a connection to a listening local socket at address path.

Use waitForConnection() to find out if the connection succeeded or not.

Parameters
paththe local socket address to connect to
typethe local socket type to use
modethe mode to use when opening (see QIODevice::OpenMode)

Definition at line 61 of file klocalsocket.cpp.

void KLocalSocket::disconnectFromHostImplementation ( )
protectedslot

Definition at line 81 of file klocalsocket.cpp.

void KLocalSocket::disconnectFromPath ( )

Disconnects the socket from its server.

Definition at line 90 of file klocalsocket.cpp.

QString KLocalSocket::localPath ( ) const

Returns the local address of this socket, when connected.

Returns QString() if not connected.

Most of the time, the socket has no local address.

Definition at line 101 of file klocalsocket.cpp.

KLocalSocket::LocalSocketType KLocalSocket::localSocketType ( ) const

Returns the socket type for this socket, when connected.

Returns UnknownLocalSocketType if not connected.

Definition at line 96 of file klocalsocket.cpp.

QString KLocalSocket::peerPath ( ) const

Returns the peer address of this socket.

That is, the address that this socket connected to (see connectToPath). Returns QString() if not connected.

Definition at line 106 of file klocalsocket.cpp.


The documentation for this class was generated from the following files:
  • klocalsocket.h
  • klocalsocket.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal