Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:58:14+00:00 2026-06-07T03:58:14+00:00

I am new to programming in vb.net. I have come a long ways in

  • 0

I am new to programming in vb.net. I have come a long ways in my development and understanding of vb, but there is one hurtle I can not seem to fix. I am hosting an ftp server on my pc and I am making an app for it to connect to my server and download files. The problem with all the sample code is that everyone ASSUMES the server WILL be ONLINE. My pc may not be running 24/7 and I also may not have the ftp service running.In the first case it shouldnt even register that it is connected. In the second case, it WILL say that is connected b/c the pc is on, but it will return that the machine ou are trying to connect to is actively refusing the connection. Is there a way to TRULY check if the program is indeed connected to the server WITHOUT generating a bunch of Exceptions in the debugger? All I want is a call like:

Dim ftponline As Boolean = False 'Set default to false
ftponline = checkftp()
If ftponline Then
'continue program
Else
'try a different server
End If   

So it would be a function called checkftp that returns a boolean value of true or false.
Here is my info:
Using Visual Studio 2010 Pro
Using .Net framework 4
Can anyone help?
Thanks!
I have tried the rebex ftp pack as well as the Ultimate FTP Pack.
Here is the updated code:

Public Function CheckConnection(address As String) As Boolean
    Dim logonServer As New System.Net.Sockets.TcpClient()
    Try
        logonServer.Connect(address, 21)
    Catch generatedExceptionName As Exception
        MessageBox.Show("Failed to connect to: " & address)
    End Try
    If logonServer.Connected Then
        MessageBox.Show("Connected to: " & address)
        Return True
        logonServer.Close()
    Else
        Return False
    End If

End Function
Public Sub ConnectFtp()
        types.Clear()
        models.Clear()
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()
        TextBox2.Clear()
        Dim request As New Rebex.Net.Ftp
        If CheckConnection(*) Then
            Dim tempString As String()
            request.Connect(*)
            request.Login(*, *)
            request.ChangeDirectory("/atc3/HD_Models")
            Dim list As Array
            list = request.GetNameList()
            Dim item As String = ""
            For Each item In list
                tempString = item.Split(New Char() {" "c})
                If types.Contains(tempString(0)) = False Then
                    types.Add(tempString(0))
                End If
                If models.Contains(item) = False Then
                    models.Add(item)
                End If
            Next
            request.Disconnect()
            request.Dispose()
        ElseIf CheckConnection(*) Then
            request.Connect(*)
            request.Login(*, *)
            request.ChangeDirectory(*)
            Dim list2 As Array
            list2 = request.GetNameList()
            Dim item2 As String = ""
            Dim tempString2 As String()
            For Each item2 In list2
                MessageBox.Show(item2)
                tempString2 = item2.Split(New Char() {" "c})
                If types.Contains(tempString2(0)) = False Then
                    types.Add(tempString2(0))
                End If
                If models.Contains(item2) = False Then
                    models.Add(item2)
                End If
            Next
            request.Disconnect()
            request.Dispose()
        End If
    End Sub

No matter what I do, the second server will not connect. I even put a messagebox to show what items were being returned in the second server, but there are no messageboxes apearing when I run the program with my server offline. Is there anyone who can help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:58:16+00:00Added an answer on June 7, 2026 at 3:58 am

    If your code is designed with proper exception catching, it shouldn’t be generating a “bunch” of exceptions. The first exception you catch should be your indication that the connection failed and your code should cease attempting to communicate at that point. If for some reason you really need to check the connectivity before attempting the FTP connection, you should be able to simply attempt to synchronously open a TCP socket to the FTP server’s port. If that works, it’s up and running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android & Java programming but have been programming in .NET for
I'm new to VB.NET programming. What I'm confused about is the different ways one
I'm fairly new to Visual Studio (specifically Visual Basic .NET) but have been programming
I'm an ASP.NET newbie, but not so new at programming in general. I'm creating
I'll admit, I am pretty new with ASP .NET programming and I have been
I'm pretty new to asp net 2.0 programming and I was wondering how can
I'm abit new to programming Android App's, however I have come across a problem,
I am relatively new to ASP.NET programming, and web programming in general. We have
I'm kinda new to WPF and .Net programming in general. I have downloaded this
I'm new to using the C#/.NET programming Language and I have created a DataGridView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.