# class KServerSocket | Monitor a port for incoming TCP/IP connections. More...
Definition | `#include <ksock.h>`
Inherits | QObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- KServerSocket ( unsigned short int _port, bool _bind )
- KServerSocket ( unsigned short int _port )
- KServerSocket ( const char *_path, bool _bind )
- KServerSocket ( const char *_path )
- virtual ~KServerSocket ()
- bool bindAndListen ()
- int socket () const
- unsigned short int port ()
- unsigned long ipv4_addr ()

#### Public Slots

- virtual void slotAccept ( int )

#### Signals

- void accepted ( KSocket* )

#### Protected Methods

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

#### Protected Members

- QSocketNotifier *notifier
- int sock
- int domain

## Detailed Description

Monitor a port for incoming TCP/IP connections.

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

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

KServerSocket ( unsigned short int _port, bool _bind ) | ### KServerSocket

Constructor.

Parameters:

_port | the port number to monitor for incoming connections.
_bind | if false you need to call bindAndListen yourself. This gives you the opportunity to set options on the socket.

KServerSocket ( unsigned short int _port ) | ### KServerSocket

Same as above with _bind true.

KServerSocket ( const char *_path, bool _bind ) | ### KServerSocket

Creates a UNIX domain server socket.

Parameters:

_path | path used for the socket.
_bind | if false you need to call bindAndListen yourself. This gives you the opportunity to set options on the socket.

KServerSocket ( const char *_path ) | ### KServerSocket

Same as above with _bind true.

~KServerSocket () | ### ~KServerSocket

[virtual]

Destructor. Closes the socket if it was not already closed.

bool bindAndListen () | ### bindAndListen

Bind the socket and start listening. This should only be called once when the constructor was called with _bind false.

Returns: true on success. false on error. On error the socket will be closed.

int socket () | ### socket

[const]

Get the file descriptor associated with the socket. Returns -1 when an error occured during construction or bindAndListen

unsigned short int port () | ### port

Returns the port number which is being monitored.

unsigned long ipv4_addr () | ### ipv4_addr

The address.

void slotAccept ( int ) | ### slotAccept

[virtual slot]

Called when someone connected to our port.

void accepted ( KSocket* ) | ### accepted

[signal]

A connection has been accepted. It is your task to delete the KSocket if it is no longer needed.

bool init ( short unsigned int ) | ### init

[protected]

bool init ( const char *_path ) | ### init

[protected]

QSocketNotifier * notifier | ### notifier

[protected]

int sock | ### sock

[protected]

int domain | ### domain

[protected]

- Version: $Id: ksock.h,v 1.42 2000/12/18 01:09:22 waba Exp $
- Author: Torben Weis <weis@stud.uni-frankfurt.de>
- Generated: root@sparc.ports.openbsd.org on Wed May 2 09:34:58 2001, using kdoc 2.0a53.