41 |
static lscp_connect_t *_lscp_connect_list_find_addr (lscp_connect_list_t *pList, struct sockaddr_in *pAddr); |
static lscp_connect_t *_lscp_connect_list_find_addr (lscp_connect_list_t *pList, struct sockaddr_in *pAddr); |
42 |
static lscp_connect_t *_lscp_connect_list_find_sock (lscp_connect_list_t *pList, lscp_socket_t sock); |
static lscp_connect_t *_lscp_connect_list_find_sock (lscp_connect_list_t *pList, lscp_socket_t sock); |
43 |
|
|
44 |
static lscp_status_t _lscp_server_udp_recv (lscp_server_t *pServer); |
static lscp_status_t _lscp_server_evt_recv (lscp_server_t *pServer); |
45 |
|
|
46 |
static void _lscp_server_thread_proc (lscp_server_t *pServer); |
static void _lscp_server_thread_proc (lscp_server_t *pServer); |
47 |
static void _lscp_server_select_proc (lscp_server_t *pServer); |
static void _lscp_server_select_proc (lscp_server_t *pServer); |
48 |
|
|
49 |
static void _lscp_server_tcp_proc (void *pvServer); |
static void _lscp_server_cmd_proc (void *pvServer); |
50 |
static void _lscp_server_udp_proc (void *pvServer); |
static void _lscp_server_evt_proc (void *pvServer); |
51 |
|
|
52 |
static void _lscp_watchdog_scan (lscp_server_t *pServer); |
static void _lscp_watchdog_scan (lscp_server_t *pServer); |
53 |
|
|
197 |
lscp_connect_t *pConnect = (lscp_connect_t *) pvConnect; |
lscp_connect_t *pConnect = (lscp_connect_t *) pvConnect; |
198 |
lscp_server_t *pServer = pConnect->server; |
lscp_server_t *pServer = pConnect->server; |
199 |
|
|
200 |
while (pServer->tcp.iState && pConnect->client.iState) { |
while (pServer->cmd.iState && pConnect->client.iState) { |
201 |
if (_lscp_connect_recv(pConnect) != LSCP_OK) |
if (_lscp_connect_recv(pConnect) != LSCP_OK) |
202 |
pConnect->client.iState = 0; |
pConnect->client.iState = 0; |
203 |
} |
} |
307 |
memcpy((char *) &addr, (char *) &(pConnect->client.addr), cAddr); |
memcpy((char *) &addr, (char *) &(pConnect->client.addr), cAddr); |
308 |
addr.sin_port = htons((short) pConnect->port); |
addr.sin_port = htons((short) pConnect->port); |
309 |
|
|
310 |
if (sendto((pConnect->server)->udp.sock, pchBuffer, cchBuffer, 0, (struct sockaddr *) &addr, cAddr) == cchBuffer) |
if (sendto((pConnect->server)->evt.sock, pchBuffer, cchBuffer, 0, (struct sockaddr *) &addr, cAddr) == cchBuffer) |
311 |
ret = LSCP_OK; |
ret = LSCP_OK; |
312 |
else |
else |
313 |
lscp_socket_perror("_lscp_connect_send: sendto"); |
lscp_socket_perror("_lscp_connect_send: sendto"); |
329 |
fprintf(stderr, "_lscp_connect_ping: pConnect=%p: addr=%s port=%d sessid=%s.\n", pConnect, inet_ntoa(pConnect->client.addr.sin_addr), pConnect->port, pConnect->sessid); |
fprintf(stderr, "_lscp_connect_ping: pConnect=%p: addr=%s port=%d sessid=%s.\n", pConnect, inet_ntoa(pConnect->client.addr.sin_addr), pConnect->port, pConnect->sessid); |
330 |
#endif |
#endif |
331 |
|
|
332 |
sprintf(szBuffer, "PING %d %s\r\n", ntohs((pConnect->server)->udp.addr.sin_port), pConnect->sessid); |
sprintf(szBuffer, "PING %d %s\r\n", ntohs((pConnect->server)->evt.addr.sin_port), pConnect->sessid); |
333 |
|
|
334 |
return _lscp_connect_send(pConnect, szBuffer, strlen(szBuffer)); |
return _lscp_connect_send(pConnect, szBuffer, strlen(szBuffer)); |
335 |
} |
} |
336 |
|
|
337 |
|
|
338 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
339 |
// TCP service (stream oriented). |
// Command service (stream oriented). |
340 |
|
|
341 |
static lscp_status_t _lscp_server_udp_recv ( lscp_server_t *pServer ) |
static lscp_status_t _lscp_server_evt_recv ( lscp_server_t *pServer ) |
342 |
{ |
{ |
343 |
lscp_status_t ret = LSCP_FAILED; |
lscp_status_t ret = LSCP_FAILED; |
344 |
struct sockaddr_in addr; |
struct sockaddr_in addr; |
348 |
lscp_connect_t *pConnect; |
lscp_connect_t *pConnect; |
349 |
|
|
350 |
cAddr = sizeof(addr); |
cAddr = sizeof(addr); |
351 |
cchBuffer = recvfrom(pServer->udp.sock, achBuffer, sizeof(achBuffer), 0, (struct sockaddr *) &addr, &cAddr); |
cchBuffer = recvfrom(pServer->evt.sock, achBuffer, sizeof(achBuffer), 0, (struct sockaddr *) &addr, &cAddr); |
352 |
if (cchBuffer > 0) { |
if (cchBuffer > 0) { |
353 |
#ifdef DEBUG |
#ifdef DEBUG |
354 |
lscp_socket_trace("_lscp_server_udp_recv: recvfrom", &addr, achBuffer, cchBuffer); |
lscp_socket_trace("_lscp_server_evt_recv: recvfrom", &addr, achBuffer, cchBuffer); |
355 |
#endif |
#endif |
356 |
// Just do a simple check for PONG events (ignore sessid). |
// Just do a simple check for PONG events (ignore sessid). |
357 |
if (strncmp(achBuffer, "PONG ", 5) == 0) { |
if (strncmp(achBuffer, "PONG ", 5) == 0) { |
361 |
} |
} |
362 |
ret = LSCP_OK; |
ret = LSCP_OK; |
363 |
} |
} |
364 |
else lscp_socket_perror("_lscp_server_udp_recv: recvfrom"); |
else lscp_socket_perror("_lscp_server_evt_recv: recvfrom"); |
365 |
|
|
366 |
return ret; |
return ret; |
367 |
} |
} |
378 |
fprintf(stderr, "_lscp_server_thread_proc: Server listening for connections.\n"); |
fprintf(stderr, "_lscp_server_thread_proc: Server listening for connections.\n"); |
379 |
#endif |
#endif |
380 |
|
|
381 |
while (pServer->tcp.iState) { |
while (pServer->cmd.iState) { |
382 |
cAddr = sizeof(struct sockaddr_in); |
cAddr = sizeof(struct sockaddr_in); |
383 |
sock = accept(pServer->tcp.sock, (struct sockaddr *) &addr, &cAddr); |
sock = accept(pServer->cmd.sock, (struct sockaddr *) &addr, &cAddr); |
384 |
if (sock == INVALID_SOCKET) { |
if (sock == INVALID_SOCKET) { |
385 |
lscp_socket_perror("_lscp_server_thread_proc: accept"); |
lscp_socket_perror("_lscp_server_thread_proc: accept"); |
386 |
pServer->tcp.iState = 0; |
pServer->cmd.iState = 0; |
387 |
} else { |
} else { |
388 |
pConnect = _lscp_connect_create(pServer, sock, &addr, cAddr); |
pConnect = _lscp_connect_create(pServer, sock, &addr, cAddr); |
389 |
if (pConnect) { |
if (pConnect) { |
421 |
FD_ZERO(&select_fds); |
FD_ZERO(&select_fds); |
422 |
|
|
423 |
// Add the listeners to the master set |
// Add the listeners to the master set |
424 |
FD_SET((unsigned int) pServer->tcp.sock, &master_fds); |
FD_SET((unsigned int) pServer->cmd.sock, &master_fds); |
425 |
FD_SET((unsigned int) pServer->udp.sock, &master_fds); |
FD_SET((unsigned int) pServer->evt.sock, &master_fds); |
426 |
|
|
427 |
// Keep track of the biggest file descriptor; |
// Keep track of the biggest file descriptor; |
428 |
// So far, it's ourself, the listener. |
// So far, it's ourself, the listener. |
429 |
if ((int) pServer->udp.sock > (int) pServer->tcp.sock) |
if ((int) pServer->evt.sock > (int) pServer->cmd.sock) |
430 |
fdmax = (int) pServer->udp.sock; |
fdmax = (int) pServer->evt.sock; |
431 |
else |
else |
432 |
fdmax = (int) pServer->tcp.sock; |
fdmax = (int) pServer->cmd.sock; |
433 |
|
|
434 |
// To start counting for regular watchdog simulation. |
// To start counting for regular watchdog simulation. |
435 |
gettimeofday(&tv1, NULL); |
gettimeofday(&tv1, NULL); |
436 |
gettimeofday(&tv2, NULL); |
gettimeofday(&tv2, NULL); |
437 |
|
|
438 |
// Main loop... |
// Main loop... |
439 |
while (pServer->tcp.iState) { |
while (pServer->cmd.iState) { |
440 |
|
|
441 |
// Use a copy of the master. |
// Use a copy of the master. |
442 |
select_fds = master_fds; |
select_fds = master_fds; |
451 |
|
|
452 |
if (iSelect < 0) { |
if (iSelect < 0) { |
453 |
lscp_socket_perror("_lscp_server_select_proc: select"); |
lscp_socket_perror("_lscp_server_select_proc: select"); |
454 |
pServer->tcp.iState = 0; |
pServer->cmd.iState = 0; |
455 |
} |
} |
456 |
else if (iSelect > 0) { |
else if (iSelect > 0) { |
457 |
// Run through the existing connections looking for data to read... |
// Run through the existing connections looking for data to read... |
458 |
for (fd = 0; fd < fdmax + 1; fd++) { |
for (fd = 0; fd < fdmax + 1; fd++) { |
459 |
if (FD_ISSET(fd, &select_fds)) { // We got one!! |
if (FD_ISSET(fd, &select_fds)) { // We got one!! |
460 |
// Is it ourselves, the TCP listener? |
// Is it ourselves, the command listener? |
461 |
if (fd == (int) pServer->tcp.sock) { |
if (fd == (int) pServer->cmd.sock) { |
462 |
// Accept the connection... |
// Accept the connection... |
463 |
cAddr = sizeof(struct sockaddr_in); |
cAddr = sizeof(struct sockaddr_in); |
464 |
sock = accept(pServer->tcp.sock, (struct sockaddr *) &addr, &cAddr); |
sock = accept(pServer->cmd.sock, (struct sockaddr *) &addr, &cAddr); |
465 |
if (sock == INVALID_SOCKET) { |
if (sock == INVALID_SOCKET) { |
466 |
lscp_socket_perror("_lscp_server_select_proc: accept"); |
lscp_socket_perror("_lscp_server_select_proc: accept"); |
467 |
pServer->tcp.iState = 0; |
pServer->cmd.iState = 0; |
468 |
} else { |
} else { |
469 |
// Add to master set. |
// Add to master set. |
470 |
FD_SET((unsigned int) sock, &master_fds); |
FD_SET((unsigned int) sock, &master_fds); |
479 |
} |
} |
480 |
} |
} |
481 |
// Done with one new connection. |
// Done with one new connection. |
482 |
} else if (fd == (int) pServer->udp.sock) { |
} else if (fd == (int) pServer->evt.sock) { |
483 |
// Or to the UDP listener? |
// Or from the event listener? |
484 |
if (_lscp_server_udp_recv(pServer) != LSCP_OK) |
if (_lscp_server_evt_recv(pServer) != LSCP_OK) |
485 |
pServer->tcp.iState = 0; |
pServer->cmd.iState = 0; |
486 |
// Done with UDP transaction. |
// Done with event transaction. |
487 |
} else { |
} else { |
488 |
// Otherwise it's trivial transaction... |
// Otherwise it's trivial transaction... |
489 |
lscp_mutex_lock(pServer->connects.mutex); |
lscp_mutex_lock(pServer->connects.mutex); |
522 |
} |
} |
523 |
|
|
524 |
|
|
525 |
static void _lscp_server_tcp_proc ( void *pvServer ) |
static void _lscp_server_cmd_proc ( void *pvServer ) |
526 |
{ |
{ |
527 |
lscp_server_t *pServer = (lscp_server_t *) pvServer; |
lscp_server_t *pServer = (lscp_server_t *) pvServer; |
528 |
|
|
534 |
|
|
535 |
|
|
536 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
537 |
// UDP service (datagram oriented). |
// Event service (datagram oriented). |
538 |
|
|
539 |
static void _lscp_server_udp_proc ( void *pvServer ) |
static void _lscp_server_evt_proc ( void *pvServer ) |
540 |
{ |
{ |
541 |
lscp_server_t *pServer = (lscp_server_t *) pvServer; |
lscp_server_t *pServer = (lscp_server_t *) pvServer; |
542 |
|
|
543 |
#ifdef DEBUG |
#ifdef DEBUG |
544 |
fprintf(stderr, "_lscp_server_udp_proc: Server waiting for events.\n"); |
fprintf(stderr, "_lscp_server_evt_proc: Server waiting for events.\n"); |
545 |
#endif |
#endif |
546 |
|
|
547 |
while (pServer->udp.iState) { |
while (pServer->evt.iState) { |
548 |
if (_lscp_server_udp_recv(pServer) != LSCP_OK) |
if (_lscp_server_evt_recv(pServer) != LSCP_OK) |
549 |
pServer->udp.iState = 0; |
pServer->evt.iState = 0; |
550 |
} |
} |
551 |
|
|
552 |
#ifdef DEBUG |
#ifdef DEBUG |
553 |
fprintf(stderr, "_lscp_server_udp_proc: Server closing.\n"); |
fprintf(stderr, "_lscp_server_evt_proc: Server closing.\n"); |
554 |
#endif |
#endif |
555 |
} |
} |
556 |
|
|
692 |
fprintf(stderr, "lscp_server_create: pServer=%p: iPort=%d.\n", pServer, iPort); |
fprintf(stderr, "lscp_server_create: pServer=%p: iPort=%d.\n", pServer, iPort); |
693 |
#endif |
#endif |
694 |
|
|
695 |
// Prepare the TCP stream server socket... |
// Prepare the command stream server socket... |
696 |
|
|
697 |
sock = socket(AF_INET, SOCK_STREAM, 0); |
sock = socket(AF_INET, SOCK_STREAM, 0); |
698 |
if (sock == INVALID_SOCKET) { |
if (sock == INVALID_SOCKET) { |
699 |
lscp_socket_perror("lscp_server_create: tcp: socket"); |
lscp_socket_perror("lscp_server_create: cmd: socket"); |
700 |
free(pServer); |
free(pServer); |
701 |
return NULL; |
return NULL; |
702 |
} |
} |
703 |
|
|
704 |
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
705 |
lscp_socket_perror("lscp_server_create: tcp: setsockopt(SO_REUSEADDR)"); |
lscp_socket_perror("lscp_server_create: cmd: setsockopt(SO_REUSEADDR)"); |
706 |
#if defined(WIN32) |
#if defined(WIN32) |
707 |
if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
if (setsockopt(sock, SOL_SOCKET, SO_DONTLINGER, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
708 |
lscp_socket_perror("lscp_server_create: tcp: setsockopt(SO_DONTLINGER)"); |
lscp_socket_perror("lscp_server_create: cmd: setsockopt(SO_DONTLINGER)"); |
709 |
#endif |
#endif |
710 |
|
|
711 |
#ifdef DEBUG |
#ifdef DEBUG |
712 |
lscp_socket_getopts("lscp_server_create: tcp", sock); |
lscp_socket_getopts("lscp_server_create: cmd", sock); |
713 |
#endif |
#endif |
714 |
|
|
715 |
cAddr = sizeof(struct sockaddr_in); |
cAddr = sizeof(struct sockaddr_in); |
719 |
addr.sin_port = htons((short) iPort); |
addr.sin_port = htons((short) iPort); |
720 |
|
|
721 |
if (bind(sock, (const struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
if (bind(sock, (const struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
722 |
lscp_socket_perror("lscp_server_create: tcp: bind"); |
lscp_socket_perror("lscp_server_create: cmd: bind"); |
723 |
closesocket(sock); |
closesocket(sock); |
724 |
free(pServer); |
free(pServer); |
725 |
return NULL; |
return NULL; |
726 |
} |
} |
727 |
|
|
728 |
if (listen(sock, 10) == SOCKET_ERROR) { |
if (listen(sock, 10) == SOCKET_ERROR) { |
729 |
lscp_socket_perror("lscp_server_create: tcp: listen"); |
lscp_socket_perror("lscp_server_create: cmd: listen"); |
730 |
closesocket(sock); |
closesocket(sock); |
731 |
free(pServer); |
free(pServer); |
732 |
return NULL; |
return NULL; |
734 |
|
|
735 |
if (iPort == 0) { |
if (iPort == 0) { |
736 |
if (getsockname(sock, (struct sockaddr *) &addr, &cAddr) == SOCKET_ERROR) { |
if (getsockname(sock, (struct sockaddr *) &addr, &cAddr) == SOCKET_ERROR) { |
737 |
lscp_socket_perror("lscp_server_create: tcp: getsockname"); |
lscp_socket_perror("lscp_server_create: cmd: getsockname"); |
738 |
closesocket(sock); |
closesocket(sock); |
739 |
free(pServer); |
free(pServer); |
740 |
} |
} |
741 |
// Make TCP and UDP ports equal? |
// Make command and event ports equal? |
742 |
iPort = ntohs(addr.sin_port); |
iPort = ntohs(addr.sin_port); |
743 |
} |
} |
744 |
|
|
745 |
lscp_socket_agent_init(&(pServer->tcp), sock, &addr, cAddr); |
lscp_socket_agent_init(&(pServer->cmd), sock, &addr, cAddr); |
746 |
|
|
747 |
#ifdef DEBUG |
#ifdef DEBUG |
748 |
fprintf(stderr, "lscp_server_create: tcp: sock=%d addr=%s port=%d.\n", pServer->tcp.sock, inet_ntoa(pServer->tcp.addr.sin_addr), ntohs(pServer->tcp.addr.sin_port)); |
fprintf(stderr, "lscp_server_create: cmd: sock=%d addr=%s port=%d.\n", pServer->cmd.sock, inet_ntoa(pServer->cmd.addr.sin_addr), ntohs(pServer->cmd.addr.sin_port)); |
749 |
#endif |
#endif |
750 |
|
|
751 |
// Prepare the UDP datagram server socket... |
// Prepare the event datagram server socket... |
752 |
|
|
753 |
sock = socket(AF_INET, SOCK_DGRAM, 0); |
sock = socket(AF_INET, SOCK_DGRAM, 0); |
754 |
if (sock == INVALID_SOCKET) { |
if (sock == INVALID_SOCKET) { |
755 |
lscp_socket_perror("lscp_server_create: udp: socket"); |
lscp_socket_perror("lscp_server_create: evt: socket"); |
756 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
757 |
free(pServer); |
free(pServer); |
758 |
return NULL; |
return NULL; |
759 |
} |
} |
760 |
|
|
761 |
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &iSockOpt, sizeof(int)) == SOCKET_ERROR) |
762 |
lscp_socket_perror("lscp_server_create: udp: setsockopt(SO_REUSEADDR)"); |
lscp_socket_perror("lscp_server_create: evt: setsockopt(SO_REUSEADDR)"); |
763 |
|
|
764 |
#ifdef DEBUG |
#ifdef DEBUG |
765 |
lscp_socket_getopts("lscp_server_create: udp", sock); |
lscp_socket_getopts("lscp_server_create: evt", sock); |
766 |
#endif |
#endif |
767 |
|
|
768 |
cAddr = sizeof(struct sockaddr_in); |
cAddr = sizeof(struct sockaddr_in); |
772 |
addr.sin_port = htons((short) iPort); |
addr.sin_port = htons((short) iPort); |
773 |
|
|
774 |
if (bind(sock, (const struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
if (bind(sock, (const struct sockaddr *) &addr, cAddr) == SOCKET_ERROR) { |
775 |
lscp_socket_perror("lscp_server_create: udp: bind"); |
lscp_socket_perror("lscp_server_create: evt: bind"); |
776 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
777 |
closesocket(sock); |
closesocket(sock); |
778 |
free(pServer); |
free(pServer); |
779 |
return NULL; |
return NULL; |
781 |
|
|
782 |
if (iPort == 0) { |
if (iPort == 0) { |
783 |
if (getsockname(sock, (struct sockaddr *) &addr, &cAddr) == SOCKET_ERROR) { |
if (getsockname(sock, (struct sockaddr *) &addr, &cAddr) == SOCKET_ERROR) { |
784 |
lscp_socket_perror("lscp_server_create: udp: getsockname"); |
lscp_socket_perror("lscp_server_create: evt: getsockname"); |
785 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
786 |
closesocket(sock); |
closesocket(sock); |
787 |
free(pServer); |
free(pServer); |
788 |
return NULL; |
return NULL; |
789 |
} |
} |
790 |
} |
} |
791 |
|
|
792 |
lscp_socket_agent_init(&(pServer->udp), sock, &addr, cAddr); |
lscp_socket_agent_init(&(pServer->evt), sock, &addr, cAddr); |
793 |
|
|
794 |
#ifdef DEBUG |
#ifdef DEBUG |
795 |
fprintf(stderr, "lscp_server_create: udp: sock=%d addr=%s port=%d.\n", pServer->udp.sock, inet_ntoa(pServer->udp.addr.sin_addr), ntohs(pServer->udp.addr.sin_port)); |
fprintf(stderr, "lscp_server_create: evt: sock=%d addr=%s port=%d.\n", pServer->evt.sock, inet_ntoa(pServer->evt.addr.sin_addr), ntohs(pServer->evt.addr.sin_port)); |
796 |
#endif |
#endif |
797 |
|
|
798 |
// Now's finally time to startup threads... |
// Now's finally time to startup threads... |
799 |
|
|
800 |
// TCP/Main service thread... |
// Command service thread... |
801 |
if (lscp_socket_agent_start(&(pServer->tcp), _lscp_server_tcp_proc, pServer, 0) != LSCP_OK) { |
if (lscp_socket_agent_start(&(pServer->cmd), _lscp_server_cmd_proc, pServer, 0) != LSCP_OK) { |
802 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
803 |
lscp_socket_agent_free(&(pServer->udp)); |
lscp_socket_agent_free(&(pServer->evt)); |
804 |
free(pServer); |
free(pServer); |
805 |
return NULL; |
return NULL; |
806 |
} |
} |
807 |
|
|
808 |
if (pServer->mode == LSCP_SERVER_THREAD) { |
if (pServer->mode == LSCP_SERVER_THREAD) { |
809 |
// UDP service thread... |
// Event service thread... |
810 |
if (lscp_socket_agent_start(&(pServer->udp), _lscp_server_udp_proc, pServer, 0) != LSCP_OK) { |
if (lscp_socket_agent_start(&(pServer->evt), _lscp_server_evt_proc, pServer, 0) != LSCP_OK) { |
811 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
812 |
lscp_socket_agent_free(&(pServer->udp)); |
lscp_socket_agent_free(&(pServer->evt)); |
813 |
free(pServer); |
free(pServer); |
814 |
return NULL; |
return NULL; |
815 |
} |
} |
840 |
|
|
841 |
// if (pServer->mode == LSCP_SERVER_THREAD) { |
// if (pServer->mode == LSCP_SERVER_THREAD) { |
842 |
// lscp_thread_join(pServer->pWatchdog); |
// lscp_thread_join(pServer->pWatchdog); |
843 |
// lscp_socket_agent_join(&(pServer->udp)); |
// lscp_socket_agent_join(&(pServer->evt)); |
844 |
// } |
// } |
845 |
lscp_socket_agent_join(&(pServer->tcp)); |
lscp_socket_agent_join(&(pServer->cmd)); |
846 |
|
|
847 |
return LSCP_OK; |
return LSCP_OK; |
848 |
} |
} |
866 |
pServer->iWatchdog = 0; |
pServer->iWatchdog = 0; |
867 |
lscp_thread_destroy(pServer->pWatchdog); |
lscp_thread_destroy(pServer->pWatchdog); |
868 |
} |
} |
869 |
lscp_socket_agent_free(&(pServer->udp)); |
lscp_socket_agent_free(&(pServer->evt)); |
870 |
lscp_socket_agent_free(&(pServer->tcp)); |
lscp_socket_agent_free(&(pServer->cmd)); |
871 |
_lscp_connect_list_free(&(pServer->connects)); |
_lscp_connect_list_free(&(pServer->connects)); |
872 |
|
|
873 |
free(pServer); |
free(pServer); |
937 |
/** |
/** |
938 |
* Register client as a subscriber of event broadcast messages. |
* Register client as a subscriber of event broadcast messages. |
939 |
* |
* |
940 |
* @param pConnect Pointer to client connection instance structure. |
* @param pConnect Pointer to client connection instance structure. |
941 |
* @param iPort UDP port number of the requesting client connection. |
* @param iPort UDP port number of the requesting client connection. |
942 |
* |
* |
943 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |