Skip to content

Commit

Permalink
default port change to 2099
Browse files Browse the repository at this point in the history
  • Loading branch information
yedf committed Jan 20, 2017
1 parent 8577763 commit 1cfbaad
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
svr->onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
svr->onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
Expand Down
4 changes: 2 additions & 2 deletions doc-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, const char* argv[]) {
//handle ctrl+c
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServer echo(&base);
int r = echo.bind("", 99);
int r = echo.bind("", 2099);
exitif(r, "bind failed %d %s", errno, strerror(errno));
echo.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
Expand Down Expand Up @@ -139,7 +139,7 @@ con->context<std::string>() = "user defined data";
###example
```c
TcpServer echo(&base);
int r = echo.bind("", 99);
int r = echo.bind("", 2099);
exitif(r, "bind failed %d %s", errno, strerror(errno));
echo.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput()); // echo data read
Expand Down
4 changes: 2 additions & 2 deletions doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, const char* argv[]) {
//注册Ctrl+C的信号处理器--退出事件分发循环
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServer echo(&base); //创建服务器
int r = echo.bind("", 99); //绑定端口
int r = echo.bind("", 2099); //绑定端口
exitif(r, "bind failed %d %s", errno, strerror(errno));
echo.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput()); // echo 读取的数据
Expand Down Expand Up @@ -142,7 +142,7 @@ TcpServer echo(&base);
###使用示例
```c
TcpServer echo(&base); //创建服务器
int r = echo.bind("", 99); //绑定端口
int r = echo.bind("", 2099); //绑定端口
exitif(r, "bind failed %d %s", errno, strerror(errno));
echo.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput()); // echo 读取的数据
Expand Down
2 changes: 1 addition & 1 deletion examples/chat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main(int argc, const char* argv[]) {
Signal::signal(SIGINT, [&]{ base.exit(); });

int userid = 1;
TcpServerPtr chat = TcpServer::startServer(&base, "", 99);
TcpServerPtr chat = TcpServer::startServer(&base, "", 2099);
exitif(chat == NULL, "start tcpserver failed");
chat->onConnCreate([&]{
TcpConnPtr con(new TcpConn);
Expand Down
2 changes: 1 addition & 1 deletion examples/codec-cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpConnPtr con = TcpConn::createConnection(&base, "127.0.0.1", 99, 3000);
TcpConnPtr con = TcpConn::createConnection(&base, "127.0.0.1", 2099, 3000);
con->setReconnectInterval(3000);
con->onMsg(new LengthCodec, [](const TcpConnPtr& con, Slice msg) {
info("recv msg: %.*s", (int)msg.size(), msg.data());
Expand Down
2 changes: 1 addition & 1 deletion examples/codec-svr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });

TcpServerPtr echo = TcpServer::startServer(&base, "", 99);
TcpServerPtr echo = TcpServer::startServer(&base, "", 2099);
exitif(echo == NULL, "start tcp server failed");
echo->onConnCreate([]{
TcpConnPtr con(new TcpConn);
Expand Down
2 changes: 1 addition & 1 deletion examples/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, const char* argv[]) {

EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr echo = TcpServer::startServer(&base, "", 99);
TcpServerPtr echo = TcpServer::startServer(&base, "", 2099);
exitif(echo == NULL, "start tcp server failed");
echo->onConnRead(
[](const TcpConnPtr& con) {
Expand Down
2 changes: 1 addition & 1 deletion examples/echo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
svr->onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
Expand Down
4 changes: 2 additions & 2 deletions examples/hsha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace handy;
int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
HSHAPtr hsha = HSHA::startServer(&base, "", 99, 4);
HSHAPtr hsha = HSHA::startServer(&base, "", 2099, 4);
exitif(!hsha, "bind failed");
Signal::signal(SIGINT, [&, hsha]{ base.exit(); hsha->exit(); signal(SIGINT, SIG_DFL);});

Expand All @@ -17,7 +17,7 @@ int main(int argc, const char* argv[]) {
return util::format("%s used %d ms", input.c_str(), ms);
});
for (int i = 0; i < 5; i ++) {
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 2099);
con->onMsg(new LineCodec, [](const TcpConnPtr& con, Slice msg) {
info("%.*s recved", (int)msg.size(), msg.data());
con->close();
Expand Down
4 changes: 2 additions & 2 deletions examples/idle-close.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
svr->onConnState([](const TcpConnPtr& con) {
if (con->getState() == TcpConn::Connected) {
Expand All @@ -15,7 +15,7 @@ int main(int argc, const char* argv[]) {
});
}
});
auto con = TcpConn::createConnection(&base, "localhost", 99);
auto con = TcpConn::createConnection(&base, "localhost", 2099);
base.runAfter(3000, [&](){base.exit();});
base.loop();
}
4 changes: 2 additions & 2 deletions examples/reconnect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
svr->onConnState([&](const TcpConnPtr& con) { //200ms后关闭连接
if (con->getState() == TcpConn::Connected)
base.runAfter(200, [con](){ info("close con after 200ms"); con->close(); });
});
TcpConnPtr con1 = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr con1 = TcpConn::createConnection(&base, "localhost", 2099);
con1->setReconnectInterval(300);
// TcpConnPtr con2 = TcpConn::createConnection(&base, "localhost", 1, 100);
// con2->setReconnectInterval(200);
Expand Down
4 changes: 2 additions & 2 deletions examples/safe-close.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ using namespace handy;
int main(int argc, const char* argv[]) {
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
TcpServerPtr svr = TcpServer::startServer(&base, "", 99);
TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
exitif(svr == NULL, "start tcp server failed");
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 2099);
std::thread th([con,&base](){
sleep(1);
info("thread want to close an connection");
Expand Down
2 changes: 1 addition & 1 deletion examples/udp-cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
UdpConnPtr con = UdpConn::createConnection(&base, "127.0.0.1", 99);
UdpConnPtr con = UdpConn::createConnection(&base, "127.0.0.1", 2099);
exitif(!con, "start udp conn failed");
con->onMsg([](const UdpConnPtr& p, Buffer buf) {
info("udp recved %lu bytes", buf.size());
Expand Down
4 changes: 2 additions & 2 deletions examples/udp-hsha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace handy;
int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
HSHAUPtr hsha = HSHAU::startServer(&base, "", 99, 1);
HSHAUPtr hsha = HSHAU::startServer(&base, "", 2099, 1);
exitif(!hsha, "bind failed");
Signal::signal(SIGINT, [&, hsha]{ base.exit(); hsha->exit(); signal(SIGINT, SIG_DFL);});

Expand All @@ -18,7 +18,7 @@ int main(int argc, const char* argv[]) {
return util::format("%s used %d ms", input.c_str(), ms);
});
for (int i = 0; i < 1; i ++) {
UdpConnPtr con = UdpConn::createConnection(&base, "localhost", 99);
UdpConnPtr con = UdpConn::createConnection(&base, "localhost", 2099);
con->onMsg([](const UdpConnPtr& con, Buffer buf) {
info("%.*s recved", (int)buf.size(), buf.data());
con->close();
Expand Down
2 changes: 1 addition & 1 deletion examples/udp-svr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main(int argc, const char* argv[]) {
setloglevel("TRACE");
EventBase base;
Signal::signal(SIGINT, [&]{ base.exit(); });
UdpServerPtr svr = UdpServer::startServer(&base, "", 99);
UdpServerPtr svr = UdpServer::startServer(&base, "", 2099);
exitif(!svr, "start udp server failed");
svr->onMsg([](const UdpServerPtr& p, Buffer buf, Ip4Addr peer) {
info("echo msg: %s to %s", buf.data(), peer.toString().c_str());
Expand Down
4 changes: 2 additions & 2 deletions examples/write-on-empty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, const char* argv[]) {
EventBase bases;
Signal::signal(SIGINT, [&]{ bases.exit(); });
TcpServer echo(&bases);
int r = echo.bind("", 99);
int r = echo.bind("", 2099);
exitif(r, "bind failed %d %s", errno, strerror(errno));
auto sendcb = [&](const TcpConnPtr& con) {
while(con->getOutput().size() == 0 && sended < total) {
Expand All @@ -37,7 +37,7 @@ int main(int argc, const char* argv[]) {
});
thread th([]{ //模拟了一个客户端,连接服务器后,接收服务器发送过来的数据
EventBase base2;
TcpConnPtr con = TcpConn::createConnection(&base2, "127.0.0.1", 99);
TcpConnPtr con = TcpConn::createConnection(&base2, "127.0.0.1", 2099);
con->onRead([](const TcpConnPtr& con){
info("recv %lu bytes", con->getInput().size());
con->getInput().clear();
Expand Down
4 changes: 2 additions & 2 deletions protobuf/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main() {

EventBase base;
TcpServer echo(&base);
int r = echo.bind("", 99);
int r = echo.bind("", 2099);
exitif(r, "bind failed %d %s", errno, strerror(errno));
ProtoMsgDispatcher dispatch;
echo.onConnRead(
Expand All @@ -45,7 +45,7 @@ int main() {
);

dispatch.onMsg<Query>(handleQuery);
TcpConnPtr cmd = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr cmd = TcpConn::createConnection(&base, "localhost", 2099);
cmd->onState([](const TcpConnPtr& con) {
if (con->getState() == TcpConn::Connected) {
Query query;
Expand Down
4 changes: 2 additions & 2 deletions raw-examples/kqueue.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* 编译:c++ -o kqueue kqueue.cc
* 运行: ./kqueue
* 测试:echo abc | nc localhost 99
* 测试:echo abc | nc localhost 2099
* 结果:abc
* 例子的echo返回了 abc
*/
Expand Down Expand Up @@ -108,7 +108,7 @@ void loop_once(int efd, int lfd, int waitms) {
}

int main() {
short port = 99;
short port = 2099;
int epollfd = kqueue();
exit_if(epollfd < 0, "kqueue failed");
int listenfd = socket(AF_INET, SOCK_STREAM, 0);
Expand Down
8 changes: 4 additions & 4 deletions test/handy.ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST(test::TestBase, TcpServer1) {
EventBase base;
ThreadPool th(2);
TcpServer delayEcho(&base);
int r = delayEcho.bind("", 99);
int r = delayEcho.bind("", 2099);
ASSERT_EQ(r, 0);
delayEcho.onConnRead(
[&th, &base](const TcpConnPtr& con) {
Expand All @@ -59,7 +59,7 @@ TEST(test::TestBase, TcpServer1) {
con->close();
}
);
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 2099);
con->onState([](const TcpConnPtr& con) {
if (con->getState() == TcpConn::Connected)
con->send("hello");
Expand All @@ -72,12 +72,12 @@ TEST(test::TestBase, TcpServer1) {
TEST(test::TestBase, kevent) {
EventBase base;
TcpServer echo(&base);
int r = echo.bind("", 99);
int r = echo.bind("", 2099);
ASSERT_EQ(r, 0);
echo.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
});
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 99);
TcpConnPtr con = TcpConn::createConnection(&base, "localhost", 2099);
con->onState([](const TcpConnPtr& con) {
if (con->getState() == TcpConn::Connected)
con->send("hello");
Expand Down

0 comments on commit 1cfbaad

Please sign in to comment.