@@ -208,7 +208,7 @@ void kissnet_init (struct misc_config_s *mc)
208
208
pthread_t cmd_listen_tid [MAX_NET_CLIENTS ];
209
209
int e ;
210
210
#endif
211
- int kiss_port = mc -> kiss_port ;
211
+ int kiss_port = mc -> kiss_port ; /* default 8001 but easily changed. */
212
212
213
213
214
214
#if DEBUG
@@ -258,14 +258,16 @@ void kissnet_init (struct misc_config_s *mc)
258
258
cmd_listen_th [client ] = (HANDLE )_beginthreadex (NULL , 0 , kissnet_listen_thread , (void * )client , 0 , NULL );
259
259
if (cmd_listen_th [client ] == NULL ) {
260
260
text_color_set (DW_COLOR_ERROR );
261
- dw_printf ("Could not create KISS socket command listening thread\n" );
261
+ dw_printf ("Could not create KISS command listening thread for client %d \n" , client );
262
262
return ;
263
263
}
264
264
#else
265
- e = pthread_create (& (cmd_listen_tid [client ]), NULL , kissnet_listen_thread , NULL );
265
+ e = pthread_create (& (cmd_listen_tid [client ]), NULL , kissnet_listen_thread , ( void * )( long ) client );
266
266
if (e != 0 ) {
267
267
text_color_set (DW_COLOR_ERROR );
268
- perror ("Could not create KISS socket command listening thread" );
268
+ dw_printf ("Could not create KISS command listening thread for client %d\n" , client );
269
+ // Replace add perror with better message handling.
270
+ perror ("" );
269
271
return ;
270
272
}
271
273
#endif
@@ -589,6 +591,10 @@ void kissnet_send_rec_packet (int chan, int kiss_cmd, unsigned char *fbuf, int f
589
591
text_color_set (DW_COLOR_ERROR );
590
592
dw_printf ("KISS TCP: Something unexpected from client application.\n" );
591
593
dw_printf ("Is client app treating this like an old TNC with command mode?\n" );
594
+ dw_printf ("This can be caused by the application sending commands to put a\n" );
595
+ dw_printf ("traditional TNC into KISS mode. It is usually a harmless warning.\n" );
596
+ dw_printf ("For best results, configure for a KISS-only TNC to avoid this.\n" );
597
+ dw_printf ("In the case of APRSISCE/32, use \"Simply(KISS)\" rather than \"KISS.\"\n" );
592
598
593
599
flen = strlen ((char * )fbuf );
594
600
if (kiss_debug ) {
@@ -623,21 +629,21 @@ void kissnet_send_rec_packet (int chan, int kiss_cmd, unsigned char *fbuf, int f
623
629
}
624
630
625
631
#if __WIN32__
626
- err = send (client_sock [client ], (char * )kiss_buff , kiss_len , 0 );
632
+ err = SOCK_SEND (client_sock [client ], (char * )kiss_buff , kiss_len );
627
633
if (err == SOCKET_ERROR )
628
634
{
629
635
text_color_set (DW_COLOR_ERROR );
630
- dw_printf ("\nError %d sending message to KISS client application. Closing connection.\n\n" , WSAGetLastError ());
636
+ dw_printf ("\nError %d sending message to KISS client %d application. Closing connection.\n\n" , WSAGetLastError (), client );
631
637
closesocket (client_sock [client ]);
632
638
client_sock [client ] = -1 ;
633
639
WSACleanup ();
634
640
}
635
641
#else
636
- err = write (client_sock [client ], kiss_buff , kiss_len );
642
+ err = SOCK_SEND (client_sock [client ], kiss_buff , kiss_len );
637
643
if (err <= 0 )
638
644
{
639
645
text_color_set (DW_COLOR_ERROR );
640
- dw_printf ("\nError sending message to KISS client application. Closing connection.\n\n" );
646
+ dw_printf ("\nError sending message to KISS client %d application. Closing connection.\n\n" , client );
641
647
close (client_sock [client ]);
642
648
client_sock [client ] = -1 ;
643
649
}
@@ -649,63 +655,6 @@ void kissnet_send_rec_packet (int chan, int kiss_cmd, unsigned char *fbuf, int f
649
655
650
656
651
657
652
- /*-------------------------------------------------------------------
653
- *
654
- * Name: read_from_socket
655
- *
656
- * Purpose: Read from socket until we have desired number of bytes.
657
- *
658
- * Inputs: fd - file descriptor.
659
- * ptr - address where data should be placed.
660
- * len - desired number of bytes.
661
- *
662
- * Description: Just a wrapper for the "read" system call but it should
663
- * never return fewer than the desired number of bytes.
664
- *
665
- * Not really needed for KISS because we are dealing with
666
- * a stream of bytes rather than message blocks.
667
- *
668
- *--------------------------------------------------------------------*/
669
-
670
- static int read_from_socket (int fd , char * ptr , int len )
671
- {
672
- int got_bytes = 0 ;
673
-
674
- #if DEBUG
675
- text_color_set (DW_COLOR_DEBUG );
676
- dw_printf ("read_from_socket (%d, %p, %d)\n" , fd , ptr , len );
677
- #endif
678
- while (got_bytes < len ) {
679
- int n ;
680
-
681
- #if __WIN32__
682
- n = recv (fd , ptr + got_bytes , len - got_bytes , 0 );
683
- #else
684
- n = read (fd , ptr + got_bytes , len - got_bytes );
685
- #endif
686
-
687
- //Would be useful to have more detailed explanation from the error code.
688
-
689
- #if DEBUG
690
- text_color_set (DW_COLOR_DEBUG );
691
- dw_printf ("read_from_socket: n = %d\n" , n );
692
- #endif
693
- if (n <= 0 ) {
694
- return (n );
695
- }
696
-
697
- got_bytes += n ;
698
- }
699
- assert (got_bytes >= 0 && got_bytes <= len );
700
-
701
- #if DEBUG
702
- text_color_set (DW_COLOR_DEBUG );
703
- dw_printf ("read_from_socket: return %d\n" , got_bytes );
704
- #endif
705
- return (got_bytes );
706
- }
707
-
708
-
709
658
/*-------------------------------------------------------------------
710
659
*
711
660
* Name: kissnet_listen_thread
@@ -739,7 +688,7 @@ static int kiss_get (int client)
739
688
740
689
/* Just get one byte at a time. */
741
690
742
- n = read_from_socket (client_sock [client ], (char * )(& ch ), 1 );
691
+ n = SOCK_RECV (client_sock [client ], (char * )(& ch ), 1 );
743
692
744
693
if (n == 1 ) {
745
694
#if DEBUG9
@@ -759,7 +708,7 @@ static int kiss_get (int client)
759
708
}
760
709
761
710
text_color_set (DW_COLOR_ERROR );
762
- dw_printf ("\nError reading KISS byte from client application %d. Closing connection .\n\n" , client );
711
+ dw_printf ("\nKISS client application %d has gone away .\n\n" , client );
763
712
#if __WIN32__
764
713
closesocket (client_sock [client ]);
765
714
#else
@@ -775,13 +724,14 @@ static THREAD_F kissnet_listen_thread (void *arg)
775
724
{
776
725
unsigned char ch ;
777
726
727
+
728
+ int client = (int )(long )arg ;
729
+
778
730
#if DEBUG
779
731
text_color_set (DW_COLOR_DEBUG );
780
- dw_printf ("kissnet_listen_thread ( socket = %d )\n" , client_sock );
732
+ dw_printf ("kissnet_listen_thread ( client = %d, socket fd = %d )\n" , client , client_sock [ client ] );
781
733
#endif
782
734
783
- int client = (int )(long )arg ;
784
-
785
735
assert (client >= 0 && client < MAX_NET_CLIENTS );
786
736
787
737
0 commit comments