MoSync 3.3
MAUtil::Server Class Reference

Encapsulates MoSync's server connections. Use this class to listen for incoming connections. More...

#include <MAUtil/Server.h>

Inheritance diagram for MAUtil::Server:
MAUtil::ConnListener

List of all members.

Public Member Functions

 Server (ServerListener *listener)
virtual ~Server ()
int start (const char *url)
int getAddr (MAConnAddr *dst)
int accept (ConnectionListener *cl)
void close ()
bool isOpen () const

Protected Member Functions

virtual void connEvent (const MAConnEventData &data)

Protected Attributes

ServerListenermListener
MAHandle mServ
ConnectionListenermCl

Detailed Description

Encapsulates MoSync's server connections. Use this class to listen for incoming connections.


Constructor & Destructor Documentation

MAUtil::Server::Server ( ServerListener listener) [inline]
virtual MAUtil::Server::~Server ( ) [virtual]

Closes the server.


Member Function Documentation

int MAUtil::Server::start ( const char *  url)

Starts the server. This involves opening a socket, binding it to a port, and, for Bluetooth, adding an entry to the service advertisement list. Once this function returns, you should call accept() to begin receiving connections.

Parameters:
urlA server URL. See maConnect() for details.
Returns:
> 0 on success, < 0 on error.

Retrieves the local address of this server.

Parameters:
dstA pointer to the struct that will receive the address.
Returns:
> 0 on success, < 0 on error.

Asynchronously accepts one incoming connection. Will cause either ServerListener::serverAccepted() or ServerListener::serverAcceptFailed() to be called when the operation is complete.

Parameters:
clWhen a connection is accepted, this will be its listener.
Returns:
> 0 on success, < 0 on error.

Closes the server. Removes its service advertisement, if any.

bool MAUtil::Server::isOpen ( ) const

Returns true if the server is open, false otherwise. The server is considered open once start() succeeds.

virtual void MAUtil::Server::connEvent ( const MAConnEventData data) [protected, virtual]

Implements MAUtil::ConnListener.


Member Data Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines