login about faq

Hello All,

I Am trying to write my first app in VB.NET 2012 using the Chilkat software. I am attempting to create a GUI-based socket server using the async methods in the "Socket" module. However, I am struggling to find a way to periodically test the "connected" status of the socket and update a label on my form. The "IsConnected" property always returns false whether my client app is connected or not.

Here is my code (timer driven):

Private Sub tmrSockCheck_Tick(sender As Object, e As EventArgs) Handles tmrSockCheck.Tick
    Select Case lblAWOSSocket.Tag
        Case "0"
            Success = Socket.BindAndListen("20003", "1")
            If Success = True Then
                lblAWOSSocket.Tag = "1"
            Else
                lblAWOSSocket.Tag = "-1"
                MessageBox.Show(Socket.LastErrorText, "Error Binding Socket", MessageBoxButtons.OK)
            End If
        Case "1"
            lblAWOSSocket.BackColor = Color.Orange
            Success = Socket.AsyncAcceptStart("0")
            If Success = True Then
                lblAWOSSocket.Tag = "2"
            Else
                lblAWOSSocket.Tag = "-1"
                MessageBox.Show(Socket.LastErrorText, "Error Initializing Socket", MessageBoxButtons.OK)
            End If
        Case "2"
            lblAWOSSocket.BackColor = Color.Yellow
            Success = Socket.AsyncAcceptSuccess And Socket.AsyncAcceptFinished
            If Success = True Then
                lblAWOSSocket.Tag = "3"
            End If
        Case "3"
            lblAWOSSocket.BackColor = Color.Green
            If Socket.IsConnected <> True Then
                lblAWOSSocket.Tag = "1"
            End If
        Case "-1"
            lblAWOSSocket.BackColor = Color.Red
    End Select

What basically happens is that the code waits for a connection and then when my client makes the connection, the connection is closed by my application and then moves through the "AsyncAcceptStart", "AsyncAcceptSuccess" / "AsyncAcceptFinished" phase of my program before it is dropped again.

Am I right in assuming that the "IsConnected" property is for a "Client" application?

Thanks, Greg

asked Mar 13 '14 at 05:21

Greg's gravatar image

Greg
111

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×60
×1

Asked: Mar 13 '14 at 05:21

Seen: 704 times

Last updated: Mar 13 '14 at 05:21

powered by OSQA