I would like to know how to loop a connection or close an existing connection. heres the code i have to connect

Imports System.Net.Sockets
Public Class Form1
    Dim clientSocket As New System.Net.Sockets.TcpClient()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
clientSocket.Connect("ServerIp Goes Here", Server port goes here Catch ex As Exception
            Me.Close()
End Try
End Sub

Recommended Answers

All 4 Replies

What does "loop a connection" mean?

What does "loop a connection" mean?

I mean like it keeps connecting over and over again

Why don't you explain what you're trying to accomplish? The behavior you're talking about is usually called "retrying" a connection. Retrying a connection or closing an existing connection are two very different tasks. It sounds like you're trying to plumb some kind of TCP connection class to connect to a server and send data?

Why don't you explain what you're trying to accomplish? The behavior you're talking about is usually called "retrying" a connection. Retrying a connection or closing an existing connection are two very different tasks. It sounds like you're trying to plumb some kind of TCP connection class to connect to a server and send data?

What i want it to do is connect disconnect connect disconnect ect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.