Hi all
I have an issue running a telnet server from the NDK. I don't seem to be able to set a socket timeout on a telnet connection.
As an example of the issue, I modified the console function in the NDK client.pjt example code as follows:
static void console( SOCKET sCon, PSA pClient )
{
char tstr[80];
struct timeval timeout;
volatile int i;
fdOpenSession(TaskSelf());
// Get our socket
scon = sCon;
/* Do a demo send/receive */
timeout.tv_sec = 10;
timeout.tv_usec = 0;
i = setsockopt(scon, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
i = fdError();
i = setsockopt(scon, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
i = fdError();
i = send(scon, "\rSend 10 chars:", 15, 0);
i = fdError();
i = recv(scon, tstr, 10, 0);
i = fdError();
// Close the console
ConPrintf("\nGoodbye\n");
// Close console thread
ConsoleClose();
fdClose( scon );
TaskExit();
}
I expect the recv call to block for a maximum of 10 seconds, and then the socket should time out and recv should return. In practice, the socket never times out and will wait for data forever. Looking at the return values from setsockopt and fderror, the attempt to set the timeout is unsuccessful as they return EBADF - Bad file descriptor.
Can anyone explain to me why I can't set the socket options in this manner, and maybe suggest a way to obtain the desired blocking behaviour?
Many thanks
Leon de Wit
DM6437
bios_5_41_04_18 (CCS3.3)
psp_1_10_03
ndk_2_0_0