FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/examples/echo_server.php at master · lcbyz/framework · GitHub
lcbyz
/
framework
Public
forked from
whcyc2002/swoole_framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
examples
/
echo_server.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (29 loc) · 1005 Bytes
Breadcrumbs
framework
/
examples
/
echo_server.php
Copy path
File metadata and controls
32 lines (29 loc) · 1005 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
define
(
'
DEBUG
'
,
'
on
'
);
define
(
"
WEBPATH
"
,
realpath
(
__DIR__
.
'
/../
'
));
require
__DIR__
.
'
/../libs/lib_config.php
'
;
//require __DIR__'/phar://swoole.phar';
Swoole
\Config::
$
debug
=
false
;
class
EchoServer
extends
Swoole
\
Protocol
\Base
{
function
onReceive
(
$
server
,
$
client_id
,
$
from_id
,
$
data
)
{
$
this
->
server
->
send
(
$
client_id
,
"
Swoole:
"
.
$
data
);
}
}
//设置PID文件的存储路径
Swoole
\
Network
\Server::
setPidFile
(
__DIR__
.
'
/echo_server.pid
'
);
Swoole
\
Network
\Server::
addOption
(
'
c|config:
'
,
"
要加载的配置文件
"
);
/**
* 显示Usage界面
* php app_server.php start|stop|reload
*/
Swoole
\
Network
\Server::
start
(
function
(
$
options
)
{
$
AppSvr
=
new
EchoServer
();
$
listenHost
=
empty
(
$
options
[
'
host
'
]) ?
'
0.0.0.0
'
:
$
options
[
'
host
'
];
$
listenPort
=
empty
(
$
options
[
'
port
'
]) ?
9501
:
$
options
[
'
port
'
];
$
server
=
Swoole
\
Network
\Server::
autoCreate
(
$
listenHost
,
$
listenPort
);
$
server
->
setProtocol
(
$
AppSvr
);
$
server
->
run
(
array
(
'
worker_num
'
=>
1
));
});
Back
|
FazBrowse Home
|
New Git URL