473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

how do you check that a tcp connection is available?

I have a multithreaded application that is acting as a printserver. the
printers area connected to the network via IP address using a symbol
clientbridge. There are times that a printer may not be available...if that
is the case the program hangs trying to connect and wont recover on its own
when the situation is resolved.

how can i go about verifying that the connection is available before
actually connecting? or is there someway to specify a timeout period?

I have tried looping and other conditional statements, but i pegged it down
finally to the fact that if it tries to connect and cant open the connection
that thread just hangs....

thanks for you help...
Eric
Nov 20 '05 #1
1 1447
Cor
Hi Eric,

You can Ping the IP adres.

Here is a link and a code Kevin Yu did make some times ago.

I dont know if the code works, I just copied it.

VB6
http://www.mvps.org/vbnet/index.html...ernet/ping.htm

http://www.mvps.org/vbnet/index.html...byhostname.htm
Made by Kevin Yu
\\\
Private Const WSADESCRIPTION_LEN = 256

<StructLayout(LayoutKind.Sequential)> _
Public Structure WSADATA

Public wVersion As Short
Dim wHighVersion As Short

<MarshalAs(UnmanagedType.ByValTStr, sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szDescription As String
<MarshalAs(UnmanagedType.ByValTStr, sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szSystemStatus As String
Public iMaxSockets As Integer
Public iMaxUdpDg As Integer
Public lpVenderInfo As IntPtr

End Structure

Private Declare Function WSAStartup Lib "wsock32" (ByVal
wVersionRequired As Integer, ByRef lpWSADATA As WSADATA) As Integer

In your codes you can use it as:

Dim Data As New WSADATA
If WSAStartup(&H201, Data) = 0 Then
'Codes of your logic
End If
///

I hope this helps a little bit?
Cor
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DaM | last post by:
Hi guys, I'm having this problem with my ASP.Net application: I was testing the whole site, and it seem to work fine. Fast and stable, but suddenly it stopped working and this error occurred:...
2
by: Thomas | last post by:
hello, which is the easiest way to check if there is a lan connection available. i have to go to a network share in my lan - but if the notebook is not connected to this lan i would like to stop...
1
by: Agnes | last post by:
in form_load, i will new a sql connection ,fill in the dataset and then close the connection. I use Netstat to check the status. (1)Open the form , The status to the SQL server is "ESTABILISHED"...
2
by: Nuno Magalhaes | last post by:
How to check for a closed http socket without losing any data? (MSDN says to send something to server). Somewhere in my code (after sending the http header in plain text) I'm doing a loop with:...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
2
by: Earl | last post by:
Is there any sort of check that can be done to see if a particular instance of SQL Server is present? I already call a method to check for connection -- if no connection, I have the user re-enter...
4
by: Fred Zuckerman | last post by:
I have a A2K database that includes some linked tables (these links are SQL views). Sometimes there are "issues" with the SQL server and the users receive a timeout error whenever they try to...
7
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get...
4
by: jaishu | last post by:
Hi all, I am in the process of developing a small Access application. i have the table locally in Access and I am using the following code to get the recordcount ( or to check if any record...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.