I've a desktop app written in Pascal/Lazarus running on a windows 7 machine with no firewall running, this program is in development and will be deployed to a windows xp system.
I've also an app written in basic4android (I've only used this for a couple of days) that communicates with the desktop app over tcp/ip.
In lazarus I am using lnet components, both programs can be either a client or server, but I really need the desktop app to be the server (multiple Android phones eventually need to connect to this).
B4a starts its server like this
If FirstTime Then
Server.Initialize(5000, "Server")
Server.Listen
.......................
Upon connection, this sub handles it (not my own code, copied from a demo)
----------------
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
ToastMessageShow("Connected", False)
Socket1 = NewSocket
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
Else
ToastMessageShow(LastException.Message, True)
End If
Server.Listen
End Sub
------------------
This works great, the desktop app connects with the android device in milliseconds, BUT !!, when trying to connect from the Android device to the desktop app (which is in server mode), this takes about TWENTY seconds.
Here's the code i use to connect to the desktop app (I've used different timeouts when trying to connect, nothing appears to work). :-
Sub Btn_Connect_Click
Vibrate.Vibrate (50)
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.2.101",5000,1000)
ToastMessageShow("Tyring to connect....", False)
End Sub
Any ideas anyone (going to check lazarus code)?, anyone had similar issues ?
I've also an app written in basic4android (I've only used this for a couple of days) that communicates with the desktop app over tcp/ip.
In lazarus I am using lnet components, both programs can be either a client or server, but I really need the desktop app to be the server (multiple Android phones eventually need to connect to this).
B4a starts its server like this
If FirstTime Then
Server.Initialize(5000, "Server")
Server.Listen
.......................
Upon connection, this sub handles it (not my own code, copied from a demo)
----------------
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
ToastMessageShow("Connected", False)
Socket1 = NewSocket
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
Else
ToastMessageShow(LastException.Message, True)
End If
Server.Listen
End Sub
------------------
This works great, the desktop app connects with the android device in milliseconds, BUT !!, when trying to connect from the Android device to the desktop app (which is in server mode), this takes about TWENTY seconds.
Here's the code i use to connect to the desktop app (I've used different timeouts when trying to connect, nothing appears to work). :-
Sub Btn_Connect_Click
Vibrate.Vibrate (50)
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.2.101",5000,1000)
ToastMessageShow("Tyring to connect....", False)
End Sub
Any ideas anyone (going to check lazarus code)?, anyone had similar issues ?
Last edited: