StreamSocketListener.ConnectionReceived Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An event that indicates that a connection was received on the StreamSocketListener object.
// Register
event_token ConnectionReceived(TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs const&> const& handler) const;
// Revoke with event_token
void ConnectionReceived(event_token const* cookie) const;
// Revoke with event_revoker
StreamSocketListener::ConnectionReceived_revoker ConnectionReceived(auto_revoke_t, TypedEventHandler<StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs const&> const& handler) const;
public event TypedEventHandler<StreamSocketListener,StreamSocketListenerConnectionReceivedEventArgs> ConnectionReceived;
function onConnectionReceived(eventArgs) { /* Your code */ }
streamSocketListener.addEventListener("connectionreceived", onConnectionReceived);
streamSocketListener.removeEventListener("connectionreceived", onConnectionReceived);
- or -
streamSocketListener.onconnectionreceived = onConnectionReceived;
Public Custom Event ConnectionReceived As TypedEventHandler(Of StreamSocketListener, StreamSocketListenerConnectionReceivedEventArgs)
Event Type
Windows requirements
App capabilities |
ID_CAP_NETWORKING [Windows Phone]
|
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.