|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|