QUdpSocket绑定失败

时间:2019-06-21 13:51:56

标签: c++ qt sockets

QT Udp套接字出现问题。 假设所有标头都正确包含在内,我在写:

QUdpSocket* s = new QUdpSocket();
bool ok = s->bind(QHostAddress::Any, 8081);
if(!ok)
{
    std::cout << "Cannot bind socket: " << s->errorString().toStdString() << std::endl;
}

输出始终为 无法绑定套接字:不支持该操作

我做了几次尝试来解决这个问题:尝试禁用防火墙,尝试仅指定端口进行绑定,在Internet中进行搜索,但是问题仍然存在。

我的体系结构是AMD64,已安装Windows 7

1 个答案:

答案 0 :(得分:1)

这是特定于平台的问题,因为抛出了UnsupportedSocketOperationError。

> library(dplyr)
> library(readr)
> tbl <- read_table("
+       141             Methanol  Gradient
+       143             Methanol  Gradient
+        82              Toluene  Gradient
+        54          Isopropanol  Gradient
+        47                Water  Gradient
+        45                Water  Gradient
+       135              Toluene Isocratic
+        82          Acetonirile Isocratic
+        91              Acetone Isocratic
+        43              Toluene     HILIC
+        31          Isopropanol     HILIC
+        97 Methyltertbutylether     HILIC
+ ",
+ col_names=c("Precursor.Ion", "Compound", "Method"),
+ col_types=cols(Precursor.Ion=col_integer(), Compound=col_character(), Method=col_character()))
> collapse <- ", "
> tbl %>%
+     group_by(Compound) %>%
+     summarize(Methods=sort(paste(unique(Method), collapse=collapse))) %>%
+     group_by(Methods) %>%
+     summarize(Compounds=sort(paste(unique(Compound), collapse=collapse)))
# A tibble: 5 x 2
  Methods                    Compounds           
  <chr>                      <chr>               
1 Gradient                   Methanol, Water     
2 Gradient, HILIC            Isopropanol         
3 Gradient, Isocratic, HILIC Toluene             
4 HILIC                      Methyltertbutylether
5 Isocratic                  Acetone, Acetonirile

我通过添加以下内容来解决:

/* 10 */ 
\value UnsupportedSocketOperationError The requested socket operation is
       not supported by the local operating system (e.g., lack of
       IPv6 support).

在调用s-> bind()之前。