小编use*_*857的帖子

SSDP协议 - 实施

我正在尝试实现SSDP协议,但我不确定它是如何工作的.SSDP通过udp发送数据,这很清楚.如果控制器连接到网络,它可以搜索具有MSEARCH消息的设备,该消息可以发送到多播地址239.255.255.250:1900.每个设备都必须收听此地址并做出响应.但我不知道他们是如何回应的.我在wireshark中看到他们用单播响应,但我不知道如何确定接收响应的端口.

编辑 - - - - - - - -

我正在尝试使用spike fuzzing框架编写ssdp fuzzer.正如我所说,我能够发送正确的数据,但无法收到回复.我将尝试粘贴一些尖峰代码并附上简要说明.有Spike结构,它代表要发送的数据(它存储实际数据,大小,协议信息......).我删除了一些变量以使其更清晰.

struct spike {

  /*total size of all data*/
  unsigned long datasize;
  unsigned char *databuf;
  unsigned char *endbuf;
  int fd; /*for holding socket or file information*/
  int proto; /*1 for tcp, 2 for udp*/
  struct sockaddr_in *destsockaddr;
};
Run Code Online (Sandbox Code Playgroud)

现在我通过udp发送数据,并希望通过以下功能接收一些响应

spike_connect_udp(target,port);
spike_send();
s_read_packet(); 
Run Code Online (Sandbox Code Playgroud)

功能实现:

int 
spike_connect_udp(char * host, int port)
{
  int fd;
  /*ahh, having udpstuff.c makes this stuff easy*/
  fd=udpconnect(host,port);
  if (fd==-1)
    {
      fprintf(stderr,"Couldn't udp connect to target\n"); …
Run Code Online (Sandbox Code Playgroud)

ssdp

6
推荐指数
2
解决办法
2万
查看次数

C#windows phone -Alignment in xaml ListBox.ItemTemplate

我想制作简单的ListBox.每行应包含2个控件,一个对齐左侧,另一个对齐右侧,这就是全部:)我尝试了多种方法,但没有任何效果.我的代码如下

<StackPanel Grid.Row="1" Margin="12,0,12,0" Grid.Column="0">
        <ListBox Name="ListBox" Margin="12,0,12,0" ItemsSource="Exercises" HorizontalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Width=">
                        <TextBlock Text="abc" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                        <TextBlock Text="def" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </StackPanel>
Run Code Online (Sandbox Code Playgroud)

(两个文本块仅用于演示,在实际应用中我想将一个文本块绑定到实际数据,而不是第二个使用按钮.)当编译这个时,两个文本块都对齐到左边,在模拟器中,似乎像一个带有文本"abcdef"的文本块.知道如何将一个文本块与右侧对齐,另一个文本块与左侧对齐吗?非常感谢 :)

xaml windows-phone-7

5
推荐指数
1
解决办法
3444
查看次数

C++ 11树上的异步操作

我正在实现一个树数据结构和一些操作.每个节点都有一些值,指向其父节点及其子节点的指针.我已经实现了一个函数max_value,它递归地遍历树并找到存储在节点中的最高值.现在,我想使用C++ 11标准实现一个异步函数.我有以下代码:

template<typename T>
T Node<T>::max_value_async(void)
{
    T current_value = p_value;
    list<future<T>> results;
    //launch tasks
    for ( auto x : p_children)
    {
        results.insert(async(std::launch::async, x.max_value));
    }
    //wait for results
    for (auto r : results)
        r.wait();
    //find highest value
    for (auto r : results)
    {
        if (current_value < r.get())
            current_value = r.get();
    }

    return current_value;
}
Run Code Online (Sandbox Code Playgroud)

但是我在启动异步功能时遇到了麻烦.怎么了?

c++ tree asynchronous c++11

3
推荐指数
1
解决办法
395
查看次数

标签 统计

asynchronous ×1

c++ ×1

c++11 ×1

ssdp ×1

tree ×1

windows-phone-7 ×1

xaml ×1