GetSocketConnected does not update to -1 if the server closes, or the connection is broken ...
When I close the server on my own account, without closing the game, the game continues to print that it is connected ...
code :
SetErrorMode(2)
// set window properties
SetWindowTitle( "socket_teste" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
Global socket as integer
socket = ConnectSocket( "127.0.0.1", 6832, 3000 )
Global isSent as integer
isSent = 0
Global LastMsg$ as String
do
print(GetSocketConnected(socket))
if (GetSocketConnected(socket) = 1)
Print("Conectado !")
if (isSent = 0)
SendSocketString(socket,"Olá")
FlushSocket(socket)
isSent = 1
endif
if (GetSocketBytesAvailable(socket) <> 0)
LastMsg$ = GetSocketString(socket)
Message(LastMsg$)
endif
else
Print("Disconnected !")
endif
Print( ScreenFPS() )
Sync()
loop
screenshot - server working :
http://prntscr.com/lgm3ca
screenshot - agk not updating :
http://prntscr.com/lgm3l9