[Implemented] OpenNetworkConnection() timeout parameter

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

[Implemented] OpenNetworkConnection() timeout parameter

Post by Psychophanta »

Yes, looking here:
http://www.purebasic.fr/english/viewtopic.php?t=32833
where Freak says:
(If you think OpenNetworkConnection() should have a timeout parameter, thats a feature request, not a bug.)
I remember that OpenNetworkConnection() blocked the running flow of the program while trying to connect to the server side, and other times it returned inmediately, so yes, i request for a timeout to make OpenNetworkConnection() to return or to keep trying. :)

EDIT:
At the moment we are forced to make workarounds like:

Code: Select all

Procedure MyOpenNetworkConnection(*conn.UTCSafe)
  *conn\connectionID=OpenNetworkConnection(*conn\UTCServer,*conn\port)
EndProcedure

Code: Select all

;... stuff ....
    Connection.UTCSafe\UTCServer=UTC(t):Connection\port=port.w
    Connection\connectionID=0
    Thread.l=CreateThread(@MyOpenNetworkConnection(),@Connection.UTCSafe)
    WaitWindowEvent(20)
    If WaitThread(Thread,1000)=0:KillThread(Thread):EndIf
; ... more stuff...
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

I bet many would like something like this and I'm also one of them.

But I don't think it's too easy to make, since even when using the socket functions in windows there is no way to specify a timeout. At least not a simple way...
I like logic, hence I dislike humans but love computers.
Post Reply