• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TDEServerSocket Class Reference

#include <ksock.h>

Inherits TQObject.

Public Slots

virtual void slotAccept (int)
 

Signals

void accepted (TDESocket *s)
 

Public Member Functions

 TDEServerSocket (unsigned short int _port, bool _bind=true)
 
 TDEServerSocket (const char *_path, bool _bind=true)
 
virtual ~TDEServerSocket ()
 
bool bindAndListen (bool suppressFailureMessages=false)
 
int socket () const
 
unsigned short int port ()
 

Protected Member Functions

bool init (unsigned short int)
 
bool init (const char *_path)
 

Protected Attributes

int sock
 

Detailed Description

Monitors a port for incoming TCP/IP connections.

Deprecated:
This class is deprecated and will be removed in the future. Please use the classes in KNetwork for new programs. In special, this class is replaced by KNetwork::KStreamSocket and KNetwork::TDEServerSocket.

You can use a TDEServerSocket to listen on a port for incoming connections. When a connection arrived in the port, a TDESocket is created and the signal accepted is raised. Make sure you always connect to this signal. If you don't the ServerSocket will create new TDESocket's and no one will delete them!

If socket() is -1 or less the socket was not created properly.

Author
Torben Weis weis@.nosp@m.stud.nosp@m..uni-.nosp@m.fran.nosp@m.kfurt.nosp@m..de

Definition at line 250 of file ksock.h.

Constructor & Destructor Documentation

◆ TDEServerSocket() [1/2]

TDEServerSocket::TDEServerSocket ( unsigned short int  _port,
bool  _bind = true 
)

Constructor.

Parameters
_portthe port number to monitor for incoming connections.
_bindif false you need to call bindAndListen yourself. This gives you the opportunity to set options on the socket.

Definition at line 301 of file ksock.cpp.

◆ TDEServerSocket() [2/2]

TDEServerSocket::TDEServerSocket ( const char *  _path,
bool  _bind = true 
)

Creates a UNIX domain server socket.

Parameters
_pathpath used for the socket.
_bindif false you need to call bindAndListen yourself. This gives you the opportunity to set options on the socket.

Definition at line 292 of file ksock.cpp.

◆ ~TDEServerSocket()

TDEServerSocket::~TDEServerSocket ( )
virtual

Destructor.

Closes the socket if it was not already closed.

Definition at line 431 of file ksock.cpp.

Member Function Documentation

◆ accepted

void TDEServerSocket::accepted ( TDESocket *  s)
signal

A connection has been accepted.

It is your task to delete the TDESocket if it is no longer needed.

WARNING: this signal is always emitted, even if you don't connect anything to it. That would mean memory loss, because the TDESockets created go to oblivion.

Parameters
sthe socket that accepted

◆ bindAndListen()

bool TDEServerSocket::bindAndListen ( bool  suppressFailureMessages = false)

Binds the socket and start listening.

This should only be called once when the constructor was called with _bind false. On error the socket will be closed.

Parameters
suppressFailureMessagessuppress warning messages generated if the socket cannot be opened.
Returns
true on success. false on error.
Warning
If suppressFailureMessages is TRUE future debugging may be made more difficult. Only set it if your application expects to bind to unavailable ports, e.g. while scanning for open ports in a range.

Definition at line 338 of file ksock.cpp.

◆ init() [1/2]

bool TDEServerSocket::init ( const char *  _path)
protected

Definition at line 310 of file ksock.cpp.

◆ init() [2/2]

bool TDEServerSocket::init ( unsigned short int  _port)
protected

Definition at line 325 of file ksock.cpp.

◆ port()

unsigned short int TDEServerSocket::port ( )

Returns the port number which is being monitored.

Returns
the port number

Definition at line 365 of file ksock.cpp.

◆ slotAccept

void TDEServerSocket::slotAccept ( int  )
virtualslot

Called when someone connected to our port.

Definition at line 412 of file ksock.cpp.

◆ socket()

int TDEServerSocket::socket ( ) const
inline

Returns the file descriptor associated with the socket.

Returns
the file descriptor, -1 when an error occurred during construction or bindAndListen

Definition at line 293 of file ksock.h.

Member Data Documentation

◆ sock

int TDEServerSocket::sock
protected

The file descriptor for this socket.

sock may be -1. This indicates that it is not connected.

Definition at line 338 of file ksock.h.


The documentation for this class was generated from the following files:
  • ksock.h
  • ksock.cpp

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.