Contents Up Previous Next

wxSocketServer

Derived from

wxSocketBase

Include files

<wx/socket.h>

Members

wxSocketServer::wxSocketServer
wxSocketServer::~wxSocketServer
wxSocketServer::Accept
wxSocketServer::AcceptWith
wxSocketServer::WaitForAccept


wxSocketServer::wxSocketServer

wxSocketServer(wxSockAddress& address, wxSockFlags flags = wxSocketBase::NONE)

Constructs a new wxSocketServer.

Parameters

address

flags


wxSocketServer::~wxSocketServer

~wxSocketServer()

Destroys a wxSocketServer object (it doesn't close the accepted connections).


wxSocketServer::Accept

wxSocketBase * Accept(bool wait = TRUE)

Creates a new object wxSocketBase and accepts an incoming 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 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 watch "connection" events, then call Accept once you know that there is an incoming connection waiting to be accepted.

Return value

Returns an opened socket connection, or NULL if an error occured or if the wait parameter was FALSE and there were no pending connections.

See also

wxSocketServer::WaitForAccept, wxSocketBase::SetNotify, wxSocketBase::Notify, wxSocketServer::AcceptWith


wxSocketServer::AcceptWith

bool AcceptWith(wxSocketBase& socket, bool wait = TRUE)

Accept an incoming connection using the specified socket object. This is useful when someone wants to inherit wxSocketBase.

Parameters

socket

Return value

Returns TRUE on success, or FALSE if an error occured or if the wait parameter was FALSE and there were no pending connections.

wxSocketServer::WaitForAccept, wxSocketBase::SetNotify, wxSocketBase::Notify, wxSocketServer::Accept


wxSocketServer::WaitForAccept

bool WaitForAccept(long seconds = -1, long millisecond = 0)

This function waits 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

seconds

millisecond

Return value

Returns TRUE if an incoming connection arrived, FALSE if the timeout expired.

See also

wxSocketServer::Accept, wxSocketServer::AcceptWith