StreamSocketListener class
Supports listening for an incoming network connection using a TCP stream socket.
Syntax
var streamSocketListener = new Windows.Networking.Sockets.StreamSocketListener();
Attributes
- ActivatableAttribute(NTDDI_WIN8)
- DualApiPartitionAttribute()
- MarshalingBehaviorAttribute(Agile)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
Members
The StreamSocketListener class has these types of members:
Constructors
The StreamSocketListener class has these constructors.
| Constructor | Description |
|---|---|
| StreamSocketListener | Creates a new StreamSocketListener object. |
Events
The StreamSocketListener class has these events.
| Event | Description |
|---|---|
| ConnectionReceived | An event that indicates that a connection was received on the StreamSocketListener object. |
Methods
The StreamSocketListener class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| 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. |
| Close [C++, JavaScript] | Closes the StreamSocketListener object. |
| Dispose [C#, VB] | Performs tasks associated with freeing, releasing, or resetting unmanaged resources. |
Properties
The StreamSocketListener class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets socket control data on a StreamSocketListener object. | |
| Read-only | Gets socket information for the StreamSocketListener object. |
Remarks
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.
Requirements
|
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 |
|
Namespace |
|
|
Metadata |
|
|
DLL |
|
|
Capabilities |
|
See also
- Other resources
- Connecting to network services (Windows Store apps using JavaScript and HTML)
- Connecting to network services (Windows Store apps using C#/VB/C++ and XAML)
- How to use advanced socket controls (Windows Store apps using JavaScript and HTML)
- How to use advanced socket controls (Windows Store apps using C#/VB/C++ and XAML)
- Quickstart: Connecting to a network resource with a stream socket (Windows Store apps using JavaScript and HTML)
- Troubleshoot and debug network connections
- Reference
- IClosable
- Object
- StreamSocket
- StreamSocketListenerConnectionReceivedEventArgs
- StreamSocketListenerControl
- StreamSocketListenerInformation
Build date: 2/25/2013
