【发布时间】:2018-02-14 10:08:00
【问题描述】:
Snapd 有documentation on a REST API。
我可以使用以下命令从 C# 连接到套接字
var snapSocket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
var snapEndpoint = new UnixEndPoint("/run/snapd.socket");
snapSocket.Connect(snapEndpoint);
var req = Encoding.ASCII.GetBytes("GET /v2/system-info HTTP/1.1");
snapSocket.Send(req, req.Length, 0);
var bytesReceived = new byte[256];
var bytes = 0;
var response = "";
do
{
bytes = snapSocket.Receive(bytesReceived, bytesReceived.Length, 0);
response = response + Encoding.ASCII.GetString(bytesReceived, 0, bytes);
} while (bytes > 0);
Console.WriteLine(response);
但一切都停在snapSocket.Receive - 永远不会发送响应。我怀疑我发送的消息有问题。
【问题讨论】:
标签: c# unix-socket snapcraft