Supports listening for an incoming network connection using a TCP stream socket.
var streamSocketListener = new Windows.Networking.Sockets.StreamSocketListener();
The StreamSocketListener class has these types of members:
The StreamSocketListener class has these constructors.
|StreamSocketListener||Creates a new StreamSocketListener object.|
The StreamSocketListener class has these events.
|ConnectionReceived||An event that indicates that a connection was received on the StreamSocketListener object.|
The StreamSocketListener class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|BindEndpointAsync||Starts a bind operation on a StreamSocketListener to a local hostname and a local service name.|
|BindServiceNameAsync||Starts a bind operation on a StreamSocketListener to a local service name.|
|Dispose [C#, VB]||Performs tasks associated with freeing, releasing, or resetting unmanaged resources.|
The StreamSocketListener class has these properties.
|Read-only||Gets socket control data on a StreamSocketListener object.|
|Read-only||Gets socket information for the StreamSocketListener object.|
The StreamSocketListener class supports listening for an incoming network connection using a TCP stream socket and accepting the connection.
The typical order of operations is as follows:
- Create the StreamSocketListener.
- Use the Control property to retrieve a StreamSocketListenerControl object and set the socket quality of service required.
- Assign the ConnectionReceived event to an event handler.
- Call the BindServiceNameAsync or BindEndpointAsync method to bind to a local TCP port or service name.
- When a connection is received, use the StreamSocketListenerConnectionReceivedEventArgs object to retrieve the Socket property with the StreamSocket object created.
- Use the StreamSocket object to send and receive data.
- Call the Close method to stop listening for and accepting incoming network connections and release all unmanaged resources associated with the StreamSocketListener object. Any StreamSocket objects created when a connection is received are unaffected and can continue to be used as needed.
Minimum supported client
|Windows 8 [Windows Store apps, desktop apps]|
Minimum supported server
|Windows Server 2012 [Windows Store apps, desktop apps]|
Minimum supported phone
|Windows Phone 8|
- Other resources
- Connecting to network services (Windows Store apps using C#/VB/C++ and XAML)
- How to use advanced socket controls (Windows Store apps using C#/VB/C++ and XAML)
- Troubleshoot and debug network connections
Build date: 2/25/2013