added information message

master
Steffen Pohle 2 years ago
parent e4574423f4
commit 32f2c40c06

@ -1,3 +1,6 @@
2023-09-16:
- added message if a connection is closed.
2022-10-31:
- fixed use of uninitialized and wrong value.

@ -179,12 +179,18 @@ void ModbusSrv::ServerThread() {
char *msg;
clients[slot] = tcp;
msg = (char*) malloc (255);
snprintf (msg, 255, "new connection from %s\n", clients[slot]->GetRemoteAddr().c_str());
snprintf (msg, 255, "new connection from %s, use slot:%d\n", clients[slot]->GetRemoteAddr().c_str(), slot);
gdk_threads_add_idle(cb_thread_network_text_add, msg);
}
else {
// no free slot, accept and close right away.
if (tcp) delete tcp;
if (tcp) {
char *msg;
msg = (char*) malloc (255);
snprintf (msg, 255, "no free slot, close connection.\n");
gdk_threads_add_idle(cb_thread_network_text_add, msg);
delete tcp;
}
}
}
@ -195,6 +201,10 @@ void ModbusSrv::ServerThread() {
if (clients[slot] != NULL) {
len = clients[slot]->ReadTimeout(inbuffer, MODBUS_IOBUFFER, 0);
if (len < 0) {
char *msg;
msg = (char*) malloc (255);
snprintf (msg, 255, "connection on slot %d closed.\n", slot);
gdk_threads_add_idle(cb_thread_network_text_add, msg);
delete clients[slot];
clients[slot] = NULL;
}

Loading…
Cancel
Save