Android Question Socket Connected always reports successful

Rusty

Well-Known Member
Licensed User
Longtime User
I am using Net lib v.1.32 and Network lib v1.25.
When I try to connect using:
Code: Copy
Socket1.Initialize("Socket1")
Try
      Socket1.Connect(Main.TCP.IPAddress, Main.TCP.Port, 100)    '.10 second timeout
Catch
End Try

Socket1_Connected always reports Successful, even when there is no connection.
Code: Copy
Sub Socket1_Connected (Successful As Boolean)
    If Successful Then                    'this always reports successful even though it isn't
        Astreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "Astreams")
    Else
        Log("Error: " & LastException)
    End If
End Sub
Am I doing something wrong?
Thanks,
Rusty
 
Erel,
Thanks for the insights. Sorry, I cut out some code in my post and cut out too much, the actual code has this log message in the catch.
Code: Copy
Log("error connecting " & Lastexception)
It seems it IS when the server side has previously connected and then "disconnects".
In my server side code, I'm running in Visual Studio and terminate the running program by clicking the STOP button, so the termination is hostile.
What is the "proper" method to close the socket in this instance? (I'm simulating a server abend).
What is the "proper" method to close the socket when the server shuts down in a non-hostile environment, i.e. the user asks the server to shut down?
Thanks,
Rusty
 
Upvote 0
The server side is properly closing the port (I believe).
However, I have just tested using different port numbers and find differing results.
I normally use port 443 which is the HTTPS port (required by a client) and this port always reports successful = true. I can only imagine that being the HTTPS port, there is something spoofing the connection out there, but don't know for sure.
I changed to the port number to port 7890 and it reports accurately True or False depending upon if the server is running or not.
Is there a port limitation or am I dreaming?
Thanks,
Rusty
 
Upvote 0
Thanks Erel
Netstat command on the tablet? I looked at it on the PC and there was no reference to port 443.
How do I run the netstat command on the tablet, or find what ports are being used?
I ran many permutations of tests yesterday using 443 and 7890 and without a doubt port 443 is "conflicted". I'd like to know what is using the port as I have a large deployment of devices, all using port 443 (and my "workaround" on this issue, which I am not satisfied with).
Using port 7890 as the only change, the system works perfectly ! with 443, it doesn't.
Rusty
 
Upvote 0
Erel, you are brilliant!
If you use the command
netstat -a
with the -a parameter, it shows ALL ports. Port 443 IS being used on the server.
Thanks!
Rusty
 
Upvote 0
Back
Top