Hello,
I am writing a simple non-ui application to send a string to a socket port and get the result.
I always receive a timeout error, but when sending direclty to port (linux) the service on the other side, answers.
What am i doing wrong !?
the result in debug window
I am writing a simple non-ui application to send a string to a socket port and get the result.
I always receive a timeout error, but when sending direclty to port (linux) the service on the other side, answers.
What am i doing wrong !?
B4X:
Sub Process_Globals
Dim AStreams As AsyncStreams
Dim Socket1 As Socket
Public SaleString As String = "4100000100"
End Sub
Sub AppStart (Args() As String)
MainSub
StartMessageLoop
End Sub
Sub MainSub
Socket1.Initialize("icash")
Socket1.Connect("192.168.0.203",10000,0)
End Sub
Sub icash_Connected(Successful As Boolean)
If Successful = True Then
AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"AStream")
sendMsg
Else
Log ("Error Connecting")
End If
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log(msg)
End Sub
Sub AStreams_Error
Log("AStreams_Error")
End Sub
Sub AStreams_Terminated
Log("AStreams_Terminated")
End Sub
Sub sendMsg
Dim buffer() As Byte
buffer = SaleString.GetBytes("UTF8")
AStreams.Write(buffer)
Log("Sending: " & SaleString)
End Sub
the result in debug window
B4X:
Waiting for debugger to connect...
Program started.
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at anywheresoftware.b4a.objects.SocketWrapper$1.run(SocketWrapper.java:140)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Error Connecting