LC_LISTEN_FOR_ALL_1 = LC_TCP + 1, // 50501\r
LC_LISTEN_FOR_ALL_2, // 50502\r
LC_LISTEN_FOR_ALL_3, // 50503\r
- LC_LISTEN_FOR_ALL_4, // 50504\r
+ LC_RECEIVE_5, // 50504\r
LC_LISTEN_FOR_ALL_5, // 50505\r
LC_LISTEN_FOR_ALL_6, // 50506\r
LC_WRITE_1, // 50507\r
LC_CONNECT_3, // 50517\r
LC_TCP_CONNECTION_1, // 50518\r
LC_WRITE_2, // 50519\r
- LC_RECEIVE_5, // 50520\r
+ LC_SERVER_CONNECTION_RUN_1, // 50520\r
+ LC_SERVER_CONNECTION_RUN_2, // 50521\r
+ LC_SERVER_CONNECTION_RUN_3, // 50522\r
};\r
\r
#if defined __WIN32__\r
LC_RECEIVE_4, i18n("too few bytes read: $1/$2 [$3]")).arg(\r
readBytes).arg(received).arg(m_peerName).end();\r
} else {\r
- m_loggerOwner->logger()->sayF(LOG_DEBUG | CAT_NETWORK, LC_RECEIVE_5,\r
- i18n("received: $1 bytes in $2 round(s) [$3]: $4")).arg(length).arg(rounds).arg(\r
- m_peerName).arg(ReByteBuffer().appendDump(data.str(), data.length(), 80).str()).end();\r
+ m_loggerOwner->logger()->sayF(LOG_DEBUG | CAT_NETWORK,\r
+ LC_RECEIVE_5,\r
+ i18n("received: $1 bytes in $2 round(s) [$3]: $4")).arg(\r
+ length).arg(rounds).arg(m_peerName).arg(\r
+ ReByteBuffer().appendDump(data.str(), data.length(), 80).str())\r
+ .end();\r
}\r
command.setLength(0);\r
if (readBytes >= 8) {\r
++m_noSent;\r
m_toSend.setLength(0);\r
int flags = 0x7b;\r
+ // add command length:\r
int rest = length + 8;\r
- m_toSend.appendInt(length | (flags << 24), "%08x");\r
+ m_toSend.appendInt(rest | (flags << 24), "%08x");\r
m_toSend.appendFix(command, -1, 8, 8, NULL);\r
m_toSend.append(data, length);\r
- rest += 8;\r
int sent = 0;\r
const char* buf = m_toSend.str();\r
int rounds = 0;\r
}\r
if (rest == 0)\r
m_loggerOwner->logger()->sayF(LOG_DEBUG | CAT_NETWORK, LC_WRITE_2,\r
- i18n("sent: $1 bytes in $2 round(s): $3 $4")).arg(length).arg(rounds)\r
- .arg(command).arg(ReByteBuffer().appendDump(data, length, 80).str()).end();\r
+ i18n("sent: $1 bytes in $2 round(s): $3 $4")).arg(length).arg(\r
+ rounds).arg(command).arg(\r
+ ReByteBuffer().appendDump(data, length, 80).str()).end();\r
}\r
\r
/**\r
void ReTCPServerConnection::run() {\r
ReByteBuffer command;\r
ReNetCommandHandler::ProcessingState rc = ReNetCommandHandler::PS_UNDEF;\r
+ m_loggerOwner->logger()->sayF(LOG_INFO | CAT_NETWORK,\r
+ LC_SERVER_CONNECTION_RUN_1, i18n("new connection to $1"))\r
+ .arg(m_name).end();\r
do {\r
receive(command, m_received);\r
rc = m_server->handler().handleNetCommand(command, m_received, this);\r
i18n("unknown command: $1 length: $2")).arg(command).arg(\r
m_received.length()).end();\r
}\r
- } while (rc != ReNetCommandHandler::PS_STOP && ! m_shouldStop);\r
- if (rc != ReNetCommandHandler::PS_STOP)\r
- m_pool->setShouldStop();\r
+ } while (rc != ReNetCommandHandler::PS_STOP && !m_shouldStop);\r
+ m_pool->setShouldStop();\r
close();\r
+ if (rc == ReNetCommandHandler::PS_STOP)\r
+ m_loggerOwner->logger()->sayF(LOG_INFO | CAT_NETWORK,\r
+ LC_SERVER_CONNECTION_RUN_2, i18n("stop signal received from $1"))\r
+ .arg(m_name).end();\r
+ else\r
+ m_loggerOwner->logger()->say(LOG_INFO | CAT_NETWORK,\r
+ LC_SERVER_CONNECTION_RUN_3, i18n("stop order received"));\r
m_id = -1;\r
}\r
\r
socklen_t lengthAddr = sizeof(struct sockaddr_in);\r
while ((clientSocket = accept(m_handleSocket,\r
(struct sockaddr *) &addrClient, &lengthAddr)) != 0) {\r
- if (! pool.shouldStop()) {\r
- m_logger->sayF(LOG_INFO | CAT_NETWORK, LC_LISTEN_FOR_ALL_4,\r
- i18n("accepted: $1")).arg(m_port).end();\r
+ if (!pool.shouldStop()) {\r
if (m_countConnections >= m_maxConnections) {\r
// close the connection at once:\r
m_logger->sayF(LOG_WARNING | CAT_NETWORK,\r
} else {\r
ReTCPServerConnection* connection = createConnection(\r
nextId++, clientSocket, addrClient);\r
-\r
if (!pool.startThread(connection)) {\r
m_logger->sayF(LOG_ERROR | CAT_PROCESS,\r
LC_LISTEN_FOR_ALL_6,\r
getLastOSError()).end();\r
reCloseSocket(clientSocket);\r
clientSocket = -1;\r
+ } else {\r
+\r
}\r
}\r
}\r
" <direction>: 'upload', 'download' or 'mixed'",\r
NULL };\r
const char* s_tcpExamples[] = { "dirtool tcp -p 5555 server",\r
- "dirtool tcp -p 5555 client localhost 10000 10",\r
- "dirtool tcp -p 5555 --buffer-size=1024 client 192.168.7.3 10 25",\r
+ "dirtool tcp -p 5555 client localhost download 10000 10",\r
+ "dirtool tcp -p 5555 --buffer-size=1024 client 192.168.7.3 upload 10 25",\r
NULL };\r
\r
const char* s_touchUsage[] =\r
tolower(direction.at(0)) == 'u');\r
} else\r
help("unknown subcommand: $1", command.str());\r
-\r
}\r
void ReDirTCP::runMixedClient(const char* ip, int port, int rounds,\r
int interval, int bufferSize) {\r
const char* command = upload ? "strlen" : "filldata";\r
ReByteBuffer message;\r
if (upload)\r
- message.appendInt(bufferSize);\r
- else\r
message.appendChar('x', bufferSize);\r
+ else\r
+ message.appendInt(bufferSize);\r
time_t lastPrint = start;\r
int64_t size = 0;\r
int duration = 0;\r
testAll();\r
} else\r
tools.usage("unknown command: ", argv[1]);\r
+ ReTCPServer::globalClose();\r
return 0;\r
}\r
\r