[Gambas-user] Timeout in class socket (gb.net)
Benoît Minisini
g4mba5 at gmail.com
Wed Sep 9 23:46:13 CEST 2020
Le 09/09/2020 à 20:01, Hans Lehmann a écrit :
> Hello,
>
> i am still experimenting with the classes Socket and ServerSocket. I
> have the problem how to use the property Socket.Timeout in a meaningful
> way. For example I want to connect to a time server on port 37 to get
> the current timestamp. But there are time servers which are not always
> reachable. Now the question: How do I intercept the timeout if I use for
> example the following source code:
>
> Public Sub btnConnect_Click()
>
> TCP_Socket.Timeout = 1000
>
> '-- TCP-Verbindung initialisieren (Host und Port)
> TCP_Socket.Host = cmbHost.Text
> If IsInteger(txbPort.Text) Then TCP_Socket.Port = Val(txbPort.Text)
>
> '-- Verbindung zum Server herstellen
> TCP_Socket.Connect()
>
> ...
>
> End
>
>
> With kind regards
>
> Hans
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
Mmm... I'm afraid this has not been taken into account, and that the
socket timeout is not used by connect().
I will try to implement an internal timer to handle connection timeout.
As a workaround, you have to start your own timer and cancel the socket
if the timer triggers before connection is established.
Regards,
--
Benoît Minisini
More information about the User
mailing list