giuliomoro
back on the project, i´m still trying to figure out what causes the blocking...
while (!Bela_stopRequested())
{
// Accept new connections
if ((client_socket = accept(server_fd, NULL, NULL)) < 0)
{
rt_printf("accept failed\n");
continue;
}
/*
// Set the client socket to non-blocking mode
int flags = fcntl(client_socket, F_GETFL, 0);
fcntl(client_socket, F_SETFL, flags | O_NONBLOCK);
rt_printf("SET NON-BLOCKING\n");
// Create a pollfd structure for the client socket
struct pollfd fds[1];
fds[0].fd = client_socket;
fds[0].events = POLLIN;
// Wait for data to be available or timeout (50ms)
int result = poll(fds, 1, 10);
rt_printf("wait for data... \n");
if (result == -1)
{
rt_printf("poll error\n");
close(client_socket);
break;
}
else if (result == 0)
{
// Timeout occurred, no data available
rt_printf("time out... \n");
continue;
}
// Data is available, receive it
int valread = recv(client_socket, buffer, BUFFER_SIZE, 0);
rt_printf("recv function \n");
if (valread > 0)
{
rt_printf("Received: %s\n", buffer);
// look for keywords
for(unsigned int n = 0; n < valread; ++n)
{
printf("%c", buffer[n]);
keyToFind[n] = buffer[n];
}
printf("\n");
char keyword[20];
char value[20];
filterKeywordAndValue(keyToFind, keyword, value);
for (unsigned int i = 0; i < NUM_KEYWORDS; i++ )
{
if ( strcmp(keyword, keywords_names[i]) == 0 ) // if keyword matches
{
// whats the match?
printf("Keyword Match!\n");
printf("Keyword: %s\n", keyword);
printf("Value: %s\n", value);
// set value for audio backend
if ( i == 0 )
{
s_uxs1.playState = atoi(value);
}
else if ( i == 1 ) // uxs2
{
s_uxs2.playState = atoi(value);
}
else if ( i == 2 ) // interrupt
{
gInterrupt = atoi(value);
}
else if ( i == 3 ) // mastervolume
{
gMasterVolume = atof(value);
}
}
}
// Send response to the client
send(client_socket, response, strlen(response), 0);
rt_printf("Response sent.\n");
}
*/
// Close the client socket
close(client_socket);
}
when i only have the uppest code part which is:
// Accept new connections
if ((client_socket = accept(server_fd, NULL, NULL)) < 0)
{
rt_printf("accept failed\n");
continue;
}
i have also the issue with BELA not responding when pressin the stop in the BELA IDE.
is there anything else i could try to track the problem? setting prints does help me to debug right now :/