StreamSocketListener.ConnectionReceived StreamSocketListener.ConnectionReceived StreamSocketListener.ConnectionReceived StreamSocketListener.ConnectionReceived StreamSocketListener.ConnectionReceived Event

Definition

An event that indicates that a connection was received on the StreamSocketListener object.

public : event TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs> ConnectionReceived
// Register
event_token ConnectionReceived(TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs> const& handler) const;

// Revoke with event_token
void ConnectionReceived(event_token const& cookie) const;

// Revoke with event_revoker
ConnectionReceived_revoker ConnectionReceived(auto_revoke_t, TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs> const& handler) const;
public event TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs> ConnectionReceived
Public Event ConnectionReceived As TypedEventHandler (Of StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs)
function onConnectionReceived(eventArgs){/* Your code */}


streamSocketListener.addEventListener("connectionReceived", onConnectionReceived);
streamSocketListener.removeEventListener("connectionReceived", onConnectionReceived);

Remarks

To listen for a connection on the StreamSocketListener object, an app must assign the ConnectionReceived event to an event handler and then call either the BindEndpointAsync or BindServiceNameAsync method to bind the StreamSocketListener to a local service name or TCP port on which to listen. To listen for Bluetooth RFCOMM, the bind is to the Bluetooth Service ID.

Note From the perspective of a StreamSocket, a Parallel Patterns Library (PPL) completion handler is done executing (and the socket is eligible for disposal) before the continuation body runs. So, to keep your socket from being disposed if you want to use it inside a continuation, you'll need to use one of the techniques described in References to StreamSockets in C++ PPL continuations.

See also