StreamSocketListener.ConnectionReceived 事件

定义

一个事件,指示在 StreamSocketListener 对象上收到了连接。

// 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) 

事件类型

Windows 要求

应用功能
ID_CAP_NETWORKING [Windows Phone]

注解

若要侦听 StreamSocketListener 对象上的连接,应用必须将 ConnectionReceived 事件分配给事件处理程序,然后调用 BindEndpointAsyncBindServiceNameAsync 方法,将 StreamSocketListener 绑定到要侦听的本地服务名称或 TCP 端口。 若要侦听蓝牙 RFCOMM,绑定到蓝牙服务 ID。

注意StreamSocket 的角度来看,并行模式库 (PPL) 完成处理程序执行 (,并且套接字在延续正文运行之前有资格进行处置) 。 因此,如果要在延续中使用它,若要防止释放套接字,需要使用 C++ PPL 延续中对 StreamSocket 的引用中所述的技术之一。

适用于

另请参阅