SocketExtensions.SetNetworkPreference Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Sets the preference for a network interface to use either cellular or non-cellular technology.
Namespace: Microsoft.Phone.Net.NetworkInformation
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
Syntax
<ExtensionAttribute> _
Public Shared Sub SetNetworkPreference ( _
socket As Socket, _
preference As NetworkSelectionCharacteristics _
)
public static void SetNetworkPreference(
this Socket socket,
NetworkSelectionCharacteristics preference
)
Parameters
- socket
Type: System.Net.Sockets..::.Socket
The network interface for which to set the preference.
- preference
Type: Microsoft.Phone.Net.NetworkInformation..::.NetworkSelectionCharacteristics
One of the enumeration values that specify the preferred type of technology.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Socket. When you use instance method syntax to call this method, omit the first parameter.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | socket is nullNothingnullptra null reference (Nothing in Visual Basic). |
NetworkException | socket is already bound. |
NetworkException | Unable to get the session handle for socket. |
NetworkException | Unable to set the network preference. |
Remarks
For more information about extension methods, see Extension Methods (C# Programming Guide) or How to: Call an Extension Method (Visual Basic).
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1
Platforms
Windows Phone
See Also
Reference
Microsoft.Phone.Net.NetworkInformation Namespace
Other Resources
How to set connection preferences for a socket for Windows Phone 8
How to set connection requirements for a socket for Windows Phone 8