Page 1 of 1
Network functions: OpenConnection()
Posted: Tue Mar 06, 2012 6:56 am
by jalih
If OpenConnection() can't establish connection, currently Hollywood application is terminated with a dialog window telling: The following network error occured: connection refused.
I think better approach would be just to return the status and possible error string:
Code: Select all
success, error$ = OpenConnection(1, "hostname", 2000)
and let user handle the connection error without quitting the application.
Re: Network functions: OpenConnection()
Posted: Tue Mar 06, 2012 9:47 am
by airsoftsoftwair
That's a flaw in the Hollywood design. I chose not to implement return codes when I started writing Hollywood because I wanted to save the programmer from the hassle of constantly having to check error codes. That's why all other functions like OpenFile(), LoadBrush() etc. do not return error codes either. The only way to check for error codes is to disable automatic error handling via
Code: Select all
ExitOnError(False)
OpenConnection(1, ...)
error = GetLastError()
ExitOnError(True)
This is pretty much overhead. I'm working on a better solution, though, because some other users have complained about the error handling as well

Re: Network functions: OpenConnection()
Posted: Tue Mar 06, 2012 3:34 pm
by jalih
Thanks, that works fine as a solution.
Now I just have to write the server part for my game and clean up the code a bit before making sources available for others to play with...
Re: Network functions: OpenConnection()
Posted: Tue Mar 06, 2012 11:12 pm
by djrikki
Yeah, thats why I keep creating base object functions to replace/enhance the standard set - so I don't have to keep specifying ExitOnError() everywhere... although I can't get really get away from it!
E.g. A typical example in a multi-windowed environment, Hollywood will gracefully fail if a window isn't open that you are trying to close - ideally I want to do check beforehand via GetAttribute() - but cannot do this either because Hollywood will gracefully fail.
Code: Select all
Function base:CloseWindow(window)
ExitOnError(False)
CloseWindow(window)
ExitOnError(True)
EndFunction
If GetAttribute(#DISPLAY,#AWINDOW,#ATTRSTATE) = #DISPSTATE_OPEN ; even though I am using a conditional IF...ENDIF structure Hollywood still throws a wobbly.
....
EndIf