Connection STATE Problem

Madz

Well-known member
Joined
Jan 22, 2003
Messages
155
Dear

I am not getting an idea about how to handel this. i have a client server program, in which server listens for connections and client connects to server
When a PC starts with client software it connects to server and in server list box it shows the avaiable list of connected clients.

now here is a problem, if we close the server software and reopen the exe file we are unable to see list of clients which are connected

on client it have tried to do this in timer that if server has closed the connections after every 3 seconds client try to check the status of connection

if not cntoServer.state <> sckConnected then

cntoServer.connect

end if

but it cause a run time error.

can any one have any idea.
 
You are telling the program this: If you are connected, connect. That makes no sense. :)

Should be like this.

If cntoServer.state <> sckConnected then

cntoServer.Connect

End if


Or:

If Not cntoServer.state = sckConnected Then

cntoServer.Connect

End If


<> mean Not Equal To

Good Luck.
 
Hello Dudes you have not checked my Coding i have written

IF NOT cn.state = sckconnected

Any how I have solved the problem using TCPCLIENT in normal it do not tell its state i have to use its protected property ACTIVE
i made a class
Code:
Imports System.Net.Sockets
Public Class mClient
    Inherits TcpClient
    Public Property Connected() As Boolean
        Get
            If Me.Active = True Then
                Return True
            Else
                Return False
            End If
        End Get
        Set(ByVal Value As Boolean)

        End Set
    End Property
End Class

no i can check it as

if Client.active = then
try to connect it
else
exit sub
end if
 
Back
Top