无法连接到本地套接字,连接被拒绝 [英] Can't connect to local socket, connection refused
问题描述
我已经在这里几天了,只是不能解决这个问题。我也把它放在Ubuntu论坛,没有听到。基本上,我有一个本地套接字在/ tmp / mysockets我在一个php脚本中创建成功 -
if(($ sock = socket_create(AF_UNIX,SOCK_STREAM,0))== b $ b {
echosocket_create()failed:reason:。 socket_strerror(socket_last_error())。 \\\
;
exit();
}
但我无法连接,通过
if(socket_connect($ sock,$ sock_str)=== false)
{
echosocket_connect $ sock_str。 失败:原因:。 socket_strerror(socket_last_ $
socket_close($ sock);
exit();
}
b $ b
这给我
警告:socket_connect():无法连接[111]:拒绝连接
在/ var / www / myscript.php在66号线上socket_connect()
/ tmp / mysockets / sock失败:reason:Connection refused
现在,我认为这可能是一个权限问题,但我有chmod 777'/ tmp,mysockets和sock,这没有关系。可能是什么问题?
所以,原来是应该在侦听这个套接字的进程崩溃 - 我在远程执行对我有用[0]丢个板砖[0]引用|举报|编辑删除管理回复次数:7
I've been at this for a few days now and just can't crack the problem. I've also put it up on the Ubuntu forum and heard nothing. Basically, I have a local socket in /tmp/mysockets which I create successfully in a php script--
if (($sock = socket_create(AF_UNIX, SOCK_STREAM,0)) === false)
{
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
exit();
}
but to which I cannot connect, via
if (socket_connect($sock, $sock_str) === false)
{
echo "socket_connect() on " . $sock_str . " failed: reason: " . socket_strerror(socket_last_$
socket_close($sock);
exit();
}
This gives me
Warning: socket_connect(): unable to connect [111]: Connection refused in /var/www/myscript.php on line 66 socket_connect() on /tmp/mysockets/sock failed: reason: Connection refused
Now, I thought this might be a permissions issue, but I've chmod 777'ed the /tmp, mysockets, and sock, and it doesn't matter. What could be the problem?
So, it turns out that the process that was supposed to be listening for this socket crashed--I'm doing this remotely (and I'm just getting used to remote compiling/debugging) so I didn't see this at first. Sorry guys I described the problem incorrectly. @duskwuff you had the right idea.
这篇关于无法连接到本地套接字,连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!