Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在xamarin forms pcl上安装System.Net.Sockets_C#_Sockets_Xamarin.forms_Tcpclient_System.net.sockets - Fatal编程技术网

C# 在xamarin forms pcl上安装System.Net.Sockets

C# 在xamarin forms pcl上安装System.Net.Sockets,c#,sockets,xamarin.forms,tcpclient,system.net.sockets,C#,Sockets,Xamarin.forms,Tcpclient,System.net.sockets,我有个问题。我需要在xamarin表单上使用TcpClient,但是“System.Net.Sockets”无法安装。我无法使用Nuget安装它 错误是: 无法安装程序包“System.Net.Sockets 4.3.0”。你在努力 将此软件包安装到目标为 “.NETPortable,Version=v4.6,Profile=Profile44”,但该包不支持 不包含任何不可用的程序集引用或内容文件 与该框架兼容。有关更多信息,请联系 包作者 在iOS和Android项目上可以安装,但在这个便

我有个问题。我需要在xamarin表单上使用TcpClient,但是“System.Net.Sockets”无法安装。我无法使用Nuget安装它

错误是:

无法安装程序包“System.Net.Sockets 4.3.0”。你在努力 将此软件包安装到目标为 “.NETPortable,Version=v4.6,Profile=Profile44”,但该包不支持 不包含任何不可用的程序集引用或内容文件 与该框架兼容。有关更多信息,请联系 包作者

在iOS和Android项目上可以安装,但在这个便携项目上不会安装

我怎样才能解决这个问题

谢谢你应该试试

tpc列表器

var listenPort = 11000;
var listener = new TcpSocketListener();

// when we get connections, read byte-by-byte from the socket's read stream
listener.ConnectionReceived += async (sender, args) => 
{
    var client = args.SocketClient; 

    var bytesRead = -1;
    var buf = new byte[1];

    while (bytesRead != 0)
    {
        bytesRead = await args.SocketClient.ReadStream.ReadAsync(buf, 0, 1);
        if (bytesRead > 0)
            Debug.Write(buf[0]);
    }
};

// bind to the listen port across all interfaces
await listener.StartListeningAsync(listenPort);
否则,您可以尝试在特定于平台的代码中实现套接字。

请参阅以下内容,了解为什么无法将套接字类安装到PCL项目中,即使它在Xamarin.iOS和Xamarin.Android中受支持


除了使用一些PCL ready socket nuget软件包外,您还可以选择将System.Net.socket安装到Android和iOS,并通过

调用它们。如果您可以在iOS和Android中安装它,那么您已经成功了一半,您可以从portable类调用它们。因为如果它不能安装在PCL上,您可以做的只是复制“System.Net.Sockets 4.3.0”的代码,并使用您需要的类。可能它使用了其他一些PCL不支持的库,这里有PCL的库…xamarin formsHi alessandro支持这个,现在我使用这个插件,但是异步模式丢失了接收字节,我想你可以在Github上打开一个问题