我目前正试图从CoAP in C#开始。我使用的库是CoAP.Net (→https://github.com/smeshlink/CoAP.NET)。
不幸的是,在“快速启动”-Section on GitHub中发布的示例中,我甚至没有成功。
我的服务器代码:
class Program
{
static void Main(string[] args)
{
CoapServer server = new CoapServer();
server.Add(new HelloWorldRessouce());
server.Start();
}
}以及服务器解决方案中的重新源类:
class HelloWorldRessouce : CoAP.Server.Resources.Resource
{
public HelloWorldRessouce() : base("hello-world")
{
Attributes.Title = "GET a friendly greeting!";
}
protected override void DoGet (CoapExchange exchange)
{
exchange.Respond("Hello World fron CoAP.NET!");
}
}在客户端,我得到了以下信息:
static void Main(string[] args)
{
CoapClient client = new CoapClient();
Request request = new Request(Method.GET);
//request.URI = new Uri("coap://[::1]/hello-world");
request.URI = new Uri("coap://192.168.178.48:5683/hello-world");
request.Send();
// wait for response
Response response = request.WaitForResponse();
}以下是服务器的控制台输出:
调试启动CoAP服务器 调试- BlockwiseLayer使用MaxMessageSize: 1024和DefaultBlockSize:512 DBEUG -绑定到::ffff:0:0:5683的起始端点 按任何键..。
下面是客户机的控制台输出:控制台-输出-客户机
我很确定,问题在客户端.
如果有人能帮我运行这个例子,那就太棒了。或者,有人可以给我举几个例子。举个例子-档案帮不了我解决这个问题.
谢谢大家..。干杯,米尔科
发布于 2017-07-24 08:34:27
好吧,好像有最蠢的用户在工作.^^
服务器端:
static void Main(string[] args)
{
CoapServer server = new CoapServer();
server.Add(new HelloWorldRessouce());
server.Start();
}在“server.Start()”之后,程序完成,服务器关闭。
然后添加一个"Console.ReadKey();“,一切都很好。
如果有人有任何关于配置的例子,尤其是关于配置的例子,他们仍然会受到赞赏。
谢谢大家;)
https://stackoverflow.com/questions/45266488
复制相似问题