- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
通过无连接数据报 Unix 套接字发送时出现 ECONNREFUSED 的可能原因是什么?
也欢迎任何有关如何调试此问题的建议,因为此问题是可重现的。
无论是否使用 sendto()
或 sendmsg()
我都会收到错误消息。
if ((sock = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0)
{
return 0;
}
unlink("/tmp/serv");
addr.sun_family = AF_UNIX;
strncpy(&addr.sun_path[0], "/tmp/serv", sizeof(addr.sun_path));
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
{
return 0;
}
sockaddr_un from;
int fromlen = sizeof(from);
if (recvfrom(sock, &i, sizeof(i),0,(sockaddr*)&from,(socklen_t*)&fromlen) < 0 )
{
//some error handling code
}
printf("from.sun_family=%d, from.sun_path=%s",from.sun_family,from.sun_path); // this prints, as expected "from.sun_family=1, from.sun_path=/tmp/client"
strncpy(&addr.sun_path[0], "/tmp/client", sizeof(addr.sun_path));
sendto(sock,"abc",3,0,(sockaddr*)&addr, sizeof(addr)); //this fails with ECONNREFUSED
最佳答案
来自 man 7 unix
:
ECONNREFUSED The remote address specified by connect(2) was not a listening socket. This error can also occur if the target filename is not a socket.
在 Linux 中,sendto
在 Unix 套接字上 does the following :
1548 if (sock_flag(other, SOCK_DEAD)) {
1549 /*
1550 * Check with 1003.1g - what should
1551 * datagram error
1552 */
1553 unix_state_unlock(other);
1554 sock_put(other);
1555
1556 err = 0;
1557 unix_state_lock(sk);
1558 if (unix_peer(sk) == other) {
1559 unix_peer(sk) = NULL;
1560 unix_state_unlock(sk);
1561
1562 unix_dgram_disconnected(sk, other);
1563 sock_put(other);
1564 err = -ECONNREFUSED;
1565 } else {
1566 unix_state_unlock(sk);
1567 }
1568
1569 other = NULL;
1570 if (err)
1571 goto out_free;
1572 goto restart;
1573 }
换句话说,您发送到的套接字的另一端没有读取器,或者套接字不再存在于文件系统中。
关于c++ - 数据报 Unix 套接字上的 ECONNREFUSED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26016189/
我正在尝试学习 AngularJS。作为其中的一部分,我想学习使用端到端测试。目前,我有一个这样的目录结构: node_modules .bin ... protractor ..
我收到了 heroku run any_command_here 的 ECONNREFUSED。 Heroku 登录成功。其他 heroku 命令也成功(应用程序、发布、共享)。应用程序正在运行。我什
我以前可以运行它。但现在我不能了。它是在一个项目中。我的 friend 从 git latst 存储库(这也是我导入的方式)拥有这个项目,可以使用 gulp protractor qa 在网关下运行
我是 node.js 和 Selenium 的新手,所以如果我没有立即提供所需的所有详细信息,请多多包涵。 这是我想在 FF 中运行的非常简单的测试(我在这里发现了很多这样的问题,但它们指的是 Chr
我在一个模拟的(facebook/google)策略上运行一些测试但是当我一个一个地运行这些测试时我遇到的问题是它正在运行但是当我同时运行它们时它们在第一次测试后不工作,连接应用程序立即失败。 我尝试
我在我的电子桌面应用程序中使用 NodeJS selenium。 "electron-chromedriver": "^4.0.0-beta.1", "selenium-webdriver": "^4
在 selenium Node js 上运行测试用例遇到错误错误:ECONNREFUSED 连接 ECONNREFUSED。 测试用例 var assert = require('assert'),
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect
我用下面的代码连接到php websocket。 serverAddr = InetAddress.getByName(ip_str); socket = new So
我正在开发一个应用程序,我想我想做的是从 android 中的服务器数据库接收数据。所以我开始运行一些教程。我找到了一个正在做我想做的事的人。但我得到: detailMessage "failed
我有两个docker-compose设置,主要服务是SPA,其中包含: nginx代理,用于端口80上的wordpress wordpress + mysql expressjs用于服务React应用
我正在尝试将一个值插入到我的数据库中,该数据库是 mydb 并且该表是使用 2 个字段用户名和密码登录的。我正在使用 express.js 和 MySQL。插入查询代码为 exports.insert
在我正在开发的 Sails.js 应用程序中,我随机遇到了一个 ECONNREFUSED 错误。我试图检查引发错误的代码片段,但没有成功。我已经将日志切换为详细(NODE_DEBUG 环境变量设置为“
我是 nodejs 和 express 的新手。我正在使用“请求”库来阅读 google.com 的内容。我不断收到连接被拒绝的错误。我从 https://github.com/request/req
所以我正在尝试编写一个discord.js 机器人!我应该将discord bot 记录在 channel 中发送到mysql 的所有消息。我在互联网上搜索过,但没有找到解决我的问题的方法。前任。 n
我正在运行一个以 mysql 作为我的数据库的 Node 应用程序(也使用 sequelize 作为 ORM)。每当我使用“node”命令运行“app.js”文件时,我都会收到错误消息: { [错误:
我使用以下方法创建了一个套接字:socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)。 根据 this ,如果我多次发送简单数据包(乘以 send() 和/或 sendto
AssertionError: null == {"name":"MongoError","message":"connect ECONNREFUSED"} 我遇到断言错误。 我尝试使用 NodeJS
我正在学习 learnyounode 教程来学习 Node.js。每当我尝试安装软件包时都会收到错误。 npm ERR! Linux 4.2.0-c9 npm ERR! argv "/home/ubu
我已尝试使用此代码从我的 android 应用程序向服务器发送数据。 try { HttpClient httpClient = new DefaultHttpClient(); Ht
我是一名优秀的程序员,十分优秀!