tdecore
TDEServerSocket Class Reference
Monitors a port for incoming TCP/IP connections. More...
#include <ksock.h>

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.
Definition at line 254 of file ksock.h.
Constructor & Destructor Documentation
TDEServerSocket::TDEServerSocket | ( | unsigned short int | _port, | |
bool | _bind = true | |||
) |
TDEServerSocket::TDEServerSocket | ( | const char * | _path, | |
bool | _bind = true | |||
) |
TDEServerSocket::~TDEServerSocket | ( | ) | [virtual] |
Member Function Documentation
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:
-
s the socket that accepted
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:
-
suppressFailureMessages suppress 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.
unsigned short int TDEServerSocket::port | ( | ) |
void TDEServerSocket::slotAccept | ( | int | ) | [virtual, slot] |
int TDEServerSocket::socket | ( | ) | const [inline] |
Member Data Documentation
int TDEServerSocket::sock [protected] |
The documentation for this class was generated from the following files: