+ Log( LOG_INFO, "Accepted connection from %s:%d.", inet_ntoa( new_addr.sin_addr ), ntohs( new_addr.sin_port));
+} /* New_Connection */
+
+
+LOCAL INT Socket2Index( INT Sock )
+{
+ INT idx;
+
+ for( idx = 0; idx < MAX_CONNECTIONS; idx++ ) if( My_Connections[idx].sock == Sock ) break;
+ assert( idx < MAX_CONNECTIONS );
+
+ return idx;
+} /* Socket2Index */
+
+
+LOCAL VOID Close_Connection( INT Idx )
+{
+ /* Verbindung schlie§en */
+
+ assert( My_Connections[Idx].sock >= 0 );
+
+ if( fclose( My_Connections[Idx].fd ) != 0 )
+ {
+ Log( LOG_ERR, "Error closing connection with %s:%d - %s", inet_ntoa( My_Connections[Idx].addr.sin_addr ), ntohs( My_Connections[Idx].addr.sin_port), strerror( errno ));
+ }
+ else
+ {
+ Log( LOG_INFO, "Closed connection with %s:%d.", inet_ntoa( My_Connections[Idx].addr.sin_addr ), ntohs( My_Connections[Idx].addr.sin_port ));
+ close( My_Connections[Idx].sock );
+ }
+
+ FD_CLR( My_Connections[Idx].sock, &My_Sockets );
+
+ My_Connections[Idx].sock = -1;
+ My_Connections[Idx].fd = NULL;
+} /* Close_Connection */
+
+
+LOCAL VOID Read_Data( INT Idx )
+{
+ /* Daten von Socket einlesen */
+
+ #define SIZE 256
+
+ CHAR buffer[SIZE];
+
+ if( ! fgets( buffer, SIZE, My_Connections[Idx].fd ))
+ {
+ Close_Connection( Idx );
+ return;
+ }
+
+ ngt_Trim_Str( buffer );
+ printf( " in: '%s'\n", buffer );
+} /* Read_Data */