Version: 2.9.4
Public Member Functions
wxSocketServer Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/socket.h>

Inheritance diagram for wxSocketServer:

Detailed Description

Todo:
describe me.

Library:  wxNet
Category:  Networking

Public Member Functions

 wxSocketServer (const wxSockAddress &address, wxSocketFlags flags=wxSOCKET_NONE)
 Constructs a new server and tries to bind to the specified address.
virtual ~wxSocketServer ()
 Destructor (it doesn't close the accepted connections).
wxSocketBaseAccept (bool wait=true)
 Accepts an incoming connection request, and creates a new wxSocketBase object which represents the server-side of the connection.
bool AcceptWith (wxSocketBase &socket, bool wait=true)
 Accept an incoming connection using the specified socket object.
bool WaitForAccept (long seconds=-1, long millisecond=0)
 Wait for an incoming connection.

List of all members.


Constructor & Destructor Documentation

wxSocketServer::wxSocketServer ( const wxSockAddress address,
wxSocketFlags  flags = wxSOCKET_NONE 
)

Constructs a new server and tries to bind to the specified address.

Before trying to accept new connections, remember to test whether it succeeded with wxSocketBase:IsOk().

Parameters:
addressSpecifies the local address for the server (e.g. port number).
flagsSocket flags (See wxSocketBase::SetFlags()).
virtual wxSocketServer::~wxSocketServer ( ) [virtual]

Destructor (it doesn't close the accepted connections).


Member Function Documentation

wxSocketBase* wxSocketServer::Accept ( bool  wait = true)

Accepts an incoming connection request, and creates a new wxSocketBase object which represents the server-side of the connection.

If wait is true and there are no pending connections to be accepted, it will wait for the next incoming connection to arrive.

Warning:
This method will block the GUI.

If wait is false, it will try to accept a pending connection if there is one, but it will always return immediately without blocking the GUI. If you want to use Accept() in this way, you can either check for incoming connections with WaitForAccept() or catch wxSOCKET_CONNECTION events, then call Accept() once you know that there is an incoming connection waiting to be accepted.

Returns:
Returns an opened socket connection, or NULL if an error occurred or if the wait parameter was false and there were no pending connections.
参照:
WaitForAccept(), wxSocketBase::SetNotify(), wxSocketBase::Notify(), AcceptWith()
bool wxSocketServer::AcceptWith ( wxSocketBase socket,
bool  wait = true 
)

Accept an incoming connection using the specified socket object.

Parameters:
socketSocket to be initialized
waitSee Accept() for more info.
Returns:
Returns true on success, or false if an error occurred or if the wait parameter was false and there were no pending connections.
参照:
WaitForAccept(), wxSocketBase::SetNotify(), wxSocketBase::Notify(), Accept()
bool wxSocketServer::WaitForAccept ( long  seconds = -1,
long  millisecond = 0 
)

Wait for an incoming connection.

Use it if you want to call Accept() or AcceptWith() with wait set to false, to detect when an incoming connection is waiting to be accepted.

Parameters:
secondsNumber of seconds to wait. If -1, it will wait for the default timeout, as set with wxSocketBase::SetTimeout().
millisecondNumber of milliseconds to wait.
Returns:
true if an incoming connection arrived, false if the timeout elapsed.
参照:
Accept(), AcceptWith(), wxSocketBase::InterruptWait()
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines