-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
631ded2
commit 7239217
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# history | ||
|
||
* Revision 595 | ||
* [changed] substitute cmdline_t with t_cmdline_t | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# @author Soo Han, Kim (princeb612.kr@gmail.com) | ||
# @desc | ||
# Revision History | ||
# Date Name Description | ||
# | ||
|
||
set (module udpserver2) | ||
file (GLOB SOURCE_FILES *.cpp) | ||
|
||
maketest (${module} SOURCE_FILES PROJECT_SDK_MODULE_DEPENDENCIES PROJECT_SDK_PLATFORM_DEPENDENCIES 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* vim: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab smarttab : */ | ||
/** | ||
* @file {file} | ||
* @author Soo Han, Kim (princeb612.kr@gmail.com) | ||
* @desc see etc/udpclient | ||
* @sa See in the following order : udpserver, udpserver2, dtlsserver | ||
* | ||
* Revision History | ||
* Date Name Description | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include <iostream> | ||
#include <sdk/sdk.hpp> | ||
|
||
using namespace hotplace; | ||
using namespace hotplace::io; | ||
using namespace hotplace::crypto; | ||
using namespace hotplace::net; | ||
|
||
test_case _test_case; | ||
t_shared_instance<logger> _logger; | ||
|
||
typedef struct _OPTION { | ||
int verbose; | ||
uint16 port; | ||
|
||
_OPTION() : verbose(0), port(9000) { | ||
// do nothing | ||
} | ||
} OPTION; | ||
t_shared_instance<t_cmdline_t<OPTION>> _cmdline; | ||
|
||
#define FILENAME_RUN _T (".run") | ||
|
||
return_t echo_server(void* param) { | ||
return_t ret = errorcode_t::success; | ||
const OPTION& option = _cmdline->value(); | ||
|
||
// todo | ||
|
||
return ret; | ||
} | ||
|
||
void run_server() { | ||
_test_case.begin("echo server"); | ||
|
||
thread thread1(echo_server, nullptr); | ||
std::string result; | ||
|
||
__try2 { thread1.start(); } | ||
__finally2 { thread1.wait(-1); } | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
#ifdef __MINGW32__ | ||
setvbuf(stdout, 0, _IOLBF, 1 << 20); | ||
#endif | ||
|
||
_cmdline.make_share(new t_cmdline_t<OPTION>); | ||
*_cmdline << t_cmdarg_t<OPTION>("-v", "verbose", [](OPTION& o, char* param) -> void { o.verbose = 1; }).optional() | ||
<< t_cmdarg_t<OPTION>("-p", "port (9000)", [](OPTION& o, char* param) -> void { o.port = atoi(param); }).optional().preced(); | ||
_cmdline->parse(argc, argv); | ||
|
||
const OPTION& option = _cmdline->value(); | ||
|
||
logger_builder builder; | ||
builder.set(logger_t::logger_stdout, option.verbose).set(logger_t::logger_flush_time, 0).set(logger_t::logger_flush_size, 0); | ||
_logger.make_share(builder.build()); | ||
|
||
#if defined _WIN32 || defined _WIN64 | ||
winsock_startup(); | ||
#endif | ||
openssl_startup(); | ||
openssl_thread_setup(); | ||
|
||
run_server(); | ||
|
||
openssl_thread_end(); | ||
openssl_cleanup(); | ||
|
||
#if defined _WIN32 || defined _WIN64 | ||
winsock_cleanup(); | ||
#endif | ||
|
||
_logger->flush(); | ||
|
||
_test_case.report(); | ||
_cmdline->help(); | ||
return _test_case.result(); | ||
} |