/***************************************************************************
                          clisten.h  -  description
                             -------------------
    begin                : Fri Mar 22 2002
    copyright            : (C) 2002 by Mathias Küster
    email                : mathen@ketelhot.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _CLISTEN_H_
#define _CLISTEN_H_

#include <dclib/dcos.h>
#include <dclib/csocket.h>
#include <dclib/cthread.h>
#include <dclib/ccallback.h>

class DLL_EXPORT CListen : public CSocket, public CThread {
public:
	/** */
	CListen();
	/** */
	~CListen();

	/** */
	int StartListen( int port );
	/** */
	void StopListen();

	/** */
	virtual void Thread( CObject * Object );

	/** callback function */
	virtual int DC_ListenCallBack( int ) { return -1; };

	/** */
	void SetCallBackFunction( _CCallback * callback );

	/** callback function */
	_CCallback * pCallback;
};

/** */
inline void CListen::SetCallBackFunction( _CCallback * callback )
{ Lock(); if ( pCallback ) delete pCallback; pCallback = callback; UnLock(); };

#endif
