Sockets in Targetting.NET 4.5.1 and Windows 8.1 / WP8.1 Library

None of the Sockets APIs (System.Net.Sockets, System.Net.WebSockets, Windows.Networking.Sockets namespaces) exist in the PCL.NET 4.5.1 target, Windows 8.1, and Windows Phone 8.1. What are my networking capabilities to access the input and output stream?

+3


source to share


1 answer


There is no socket API at all between the full .Net 4.5.1 Framework (using System.Net) and the Windows Runtime (using Windows.Networking). Since the PCL allows cross-over APIs for all PCL purposes, this means the Socket API is not directly available in that PCL. You will need to open the socket in platform-specific code.

All of these targets support .Net Streams, so once you've opened a socket in a platform-specific code, you can stream the socket to the PCL for processing.



You can use Inversion of Control to have the PCL request a stream from the host when needed. The PCL can define an interface (for example, IPlatformSpecificCode) that the host can implement. When PCL wants to open a network connection, it can call IPlatformSpecificCode.OpenPlatformSpecificSocket (address, port) and the host can open System.Net.Sockets.Socket or Windows.Networking.Sockets.StreamSocket and return .Net stream for PCL to use.

+1


source







All Articles