CheckConnection Method

Summary
Determines whether the server exists without making a connection.
Syntax
C#
C++/CLI
[DispIdAttribute(1)] 
void CheckConnection(  
   string URL, 
   int Flags, 
   int Timeout 
) 
[DispIdAttribute(1)] 
void CheckConnection(  
   String^ URL, 
   int Flags, 
   int Timeout 
)              

Parameters

URL
A System.String that contains the server address to be checked.

Flags
Value that indicates whether the method should negotiate the user name and password. Possible values are:

Value Meaning
0 Do not negotiate the user name and password.
NetSrc_CC_ForceConnection Negotiate the user name and password.

Timeout
Value that represents the amount of time, in milliseconds, to wait for the connection check before failing.

Return Value

S_OK if the function was successful.

<>S_OK if an error occurred. Refer to the Error Codes or the HRESULT error codes in the DirectShow documentation.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public bool _result = false; 
public CaptureAndPlayCtrlForm _serverAndClient = new CaptureAndPlayCtrlForm(); 
 
CaptureCtrl _captureCtrl; 
PlayCtrl _playCtrl; 
 
const string _networkUrl = @"ltsf://127.0.0.1:27015"; // network stream url 
const string _testMessage = "LEAD NETWORK"; 
 
public void NetworkSourceExample() 
{ 
   // reference the capture control 
   _captureCtrl = _serverAndClient.CaptureCtrl; 
 
   // reference the play control 
   _playCtrl = _serverAndClient.PlayCtrl; 
 
   try 
   { 
      // try to find a video camera 
      if (_captureCtrl.VideoDevices["Logitech"] == null) 
         throw new Exception("No Logitech video device available"); 
 
      _captureCtrl.VideoDevices["Logitech"].Selected = true; 
 
      // select a video compressor 
      _captureCtrl.VideoCompressors.Mpeg4.Selected = true; 
 
      // set the target output file 
      _captureCtrl.TargetFormat = TargetFormatType.NET; 
      _captureCtrl.TargetFile = _networkUrl; 
 
      if (_captureCtrl.IsModeAvailable(CaptureMode.Video)) 
      { 
         // just 10 seconds of capture time 
         _captureCtrl.TimeLimit = 10; 
         _captureCtrl.UseTimeLimit = true; 
 
         _captureCtrl.FrameRate = 30; 
         _captureCtrl.UseFrameRate = true; 
 
         _captureCtrl.Preview = true; 
 
         // subscribe to the started and progress events for this example 
         // we will connect a client after the capture starts 
         _captureCtrl.Started += new EventHandler(CaptureCtrl_Started); 
 
         // ready the capture graph in order to get the LNMetMux instance 
         _captureCtrl.ReadyCapture(CaptureMode.Video); 
 
         // start capture 
         _captureCtrl.StartCapture(CaptureMode.Video); 
 
         // we'll loop on the state and pump messages for this example. 
         // but you should not need to if running from a Windows Forms application. 
         while (_captureCtrl.State == CaptureState.Running 
               || _playCtrl.State == PlayState.Running) 
         { 
            Application.DoEvents(); 
         } 
      } 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
void CaptureCtrl_Started(object sender, EventArgs e) 
{ 
   StartClient(); 
} 
 
private void StartClient() 
{ 
   try 
   { 
      LMNetSrc netSrc = new LMNetSrc(); 
      netSrc.CheckConnection(_networkUrl, 0, 5000); 
      _result = true; 
      Marshal.ReleaseComObject(netSrc); 
   } 
   catch (COMException) 
   { 
      // could not connect 
      _result = false; 
      return; 
   } 
 
   // connects the client player 
   _playCtrl.SourceFile = _networkUrl; 
} 
Requirements

Target Platforms

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.