[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] MiNTNet: connect timeout?



Bonsoir,

Thanks Ole and Jean-François, my problem is in fact non-blocking sockets. Your responses helped me.

> But I doubt this is what you encounter here....

I looked with more care in the Gluestick sources, and the gs_connect() function has commented code between #if 0 and #endif.
Inside this commented code, there's what to set non-blocking mode.

I do not know why, but the result is when a STiK/STinG client want to connect to a non-responding site (wrong ip or wrong port) using Gluestik, it hangs without timeout and the only thing is to kill the client. Someone complained here long ago (without telling me) that Litchi was blocked that way.

So I will put some mintnet calls (thanks to Lonny Pursell) to test the connection with non-blocking socket.

Regards,

Pierre
http://rajah.atari.org


Le 04/01/13 22:49, Ole a écrit :
Am Freitag, den 04.01.2013, 04:35 +0100 schrieb Pierre Ton-That <ptonthat@club-internet.fr>:
Hi,

Facing a blocking problem when doing a tcp_open with STinG and/or
Gluestik. I tried to use MiNTNet socket and fconnect, but it seems
it's also blocked at connection attempt.

During my work on Draconis Emailer and the other draconis internet tools
I encountered problems with blocking sockets. From what I understood,
it was the result of some difference between the Draconis network API and the MiNT network API. On the other hand, why did nobody hit the problem before the Firebee era. (Maybe because of the Mint 1.17 bugfix for connect()/select() - see below).
But I doubt this is what you encounter here....

Is there a way to test an opened port(s) before the connection
attempt, or use a timeout in the connect function? Or do programs use
a separate process they can kill if connection is too long?

Set the socket to be no-blocking before you do connect(),
Then do something like:

connect();
select(10sec timeout);
parse_select_result();

Additional Info:
select() + connect() combination was fixed in MiNT 1.17. There was a bug, where select reported connection success, altough the connection wasn't yet established.

Greets,
Ole