Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发现多余代码 #3

Open
twomiao opened this issue Dec 26, 2020 · 0 comments
Open

发现多余代码 #3

twomiao opened this issue Dec 26, 2020 · 0 comments

Comments

@twomiao
Copy link

twomiao commented Dec 26, 2020

代码如下:
`
list($scheme, $address) = explode(':', $this->_socketName, 2);

//only support tcp & udp currently
if(!in_array(strtolower($scheme), array('tcp', 'udp')))
{
self::showHelpByeBye('only support TCP & UDP protocol currently ...'); // 1. unixsocket 直接exit(0);
}

$this->transport = $scheme;
$local_socket = self::$_builtinTransports[$this->transport] . ":" . $address;

//flag
$flags = $this->transport === 'udp' ? STREAM_SERVER_BIND : STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
$errno = 0;
$errmsg = '';

//create an Internet or Unix domain server socket
$this->_mainSocket = stream_socket_server($local_socket, $errno, $errmsg, $flags, $this->_context);
if(!$this->_mainSocket) throw new \Exception($errmsg);

if($this->transport === 'ssl')
{
stream_socket_enable_crypto($this->_mainSocket, false);
}
elseif($this->transport === 'unix') // 2. 既然都不支持unixsocket 为何还要存在这段代码?
{ // 3.. 这样不是多余了?
$socket_file = substr($address, 2);
$this->user && chown($socket_file, $this->user);
$this->group && chgrp($socket_file, $this->group);
}
`

上面仅支持TCP,UDP,为何还要加入Unixsock 文件创建?Workerman 本身也支持UnixSocket 监听的哦~~~

@twomiao twomiao changed the title 发现一个问题,不知道对不对。 发现多余代码 Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant