L_DicomConnectExt

#include "ltdic.h"

L_LTDIC_API L_INT L_DicomConnectExt(hNet, pszHostAddress, nHostPort, pszPeerAddress, nPeerPort, nIpType)

HDICOMNET hNet;

a DICOM Network handle

L_TCHAR * pszHostAddress;

host IP address

L_UINT nHostPort;

host port number

L_TCHAR * pszPeerAddress;

peer IP address

L_UINT nPeerPort;

peer port number

L_INT nIpType;

type of IP address

Connects an SCU to an SCP. This function is available in the Medical Imaging SuiteMedical Imaging Suite Toolkit.

Parameter Description
hNet A DICOM Network handle. This is the handle returned from the L_DicomCreateNet function.
pszHostAddress Character string that contains the IP address of the host computer (the client's address).
nHostPort Port number of the host (the client's port).
pszPeerAddress Character string that contains the IP address of the peer computer to which to connect (the server's address).
nPeerPort Port number of the peer computer to which to connect (the server's port).
nIpType The type of IP address.  Possible values are:
  Value Meaning
  DICOM_IPTYPE_NONE [0x000] Provided for initialization.
  DICOM_IPTYPE_IPV4 [0x001] Only use IPv4 addresses.
  DICOM_IPTYPE_IPV6 [0x002] Only use IPv6 addresses.
  DICOM_IPTYPE_IPV4_OR_IPV6 [0x003] Use both IPv4 and IPv6 addresses.

Returns

DICOM_SUCCESS

The function was successful.

>0

An error occurred. Refer to Return Codes.

Comments

L_DicomConnectExt() is an extension of L_DicomConnect() that allows you to specify which type of Internet Protocol Version to use.If pszHostAddress is "" or NULL, the IP address will be the local computer's address.

If nHostPort is 0, the port number will be the number of the first available port.  In most cases, you should pass 0 for this parameter.  If you pass any port number other than 0, that port number will be used for the first connection and when you close the connection, LEADTOOLS will wait for the internal TCP timeout before releasing the port. This may lead to problems reconnecting.  If you pass 0, then on subsequent connections LEADTOOLS will use the next available port.

To connect to a server as a client, you must first create and initialize a handle to the DICOM Network using L_DicomCreateNet. Next, set the callback functions you will use by calling L_DicomSetCallback. Then call L_DicomConnect to establish the connection.

To use your computer as a server, you must first create and initialize a handle to the DICOM Network using L_DicomCreateNet. Next, set the callback functions you will use by calling L_DicomSetCallback. Then call L_DicomListen to listen for incoming connection requests.

When a client calls this function, it generates an ACCEPTCALLBACK function call on the server, provided the server has set the ACCEPTCALLBACK using L_DicomSetCallback.

L_DicomConnectExt() is an extension of L_DicomConnect() that allows you to specify which type of Internet Protocol Version to use.  Pass DICOM_IPTYPE_IPV4 for nIpType to support the Internet Protocol version 4 (IPv4), which is the standard  "dotted quad" 32-bit address format that has been in use since 1981. An example of an IPv4 address is 192.168.0.195

Pass DICOM_IPTYPE_IPV6 for nIpType to support Internet Protocol Version Version 6 (IPv6).  IPv6 uses a 128-bit address format.  An example of an IPv6 address is fe80::18bd:81f:6b02:759f

To support both IPv4 and Ipv6 addresses, pass DICOM_IPTYPE_IPV6 for nIpType.

If the call to L_DicomConnectExt fails, make sure that the IP address that you passed for pszHostAddress is a valid address that is accessible within your network.  You can verify the accessibility of both IPv4 and IPv6 addresses using the windows ping command.  For example, to verify that 192.168.0.195 is accessible within your network, perform the following steps:

1. Launch a command prompt, and type the following command:

2. ping 192.168.0.195

Note that the following are equivalent:

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_DicomCreateNet, L_DicomStartUp, L_DicomListen, L_DicomConnect, L_DicomListenExt

Topics:

Working with DICOM Network Connections

Example

This sample implements a very basic client, that attempts to connect to a server using an IPv6 address. Run the L_DicomListenExt sample first (a server), and then run this sample which will conect to the server. Note that you will need to change the szPeerIP IPv6 address to be the valid IPv6 address on your network where the L_DicomListenExt sample is running.

L_VOID EXT_CALLBACK OnConnectCB(HDICOMNET hNet, L_INT nError, L_VOID *pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   UNREFERENCED_PARAMETER(hNet); 
   if (nError != DICOM_SUCCESS) 
      MessageBox(NULL, TEXT("Connection refused"), TEXT("Notice"), MB_OK); 
   else 
      MessageBox(NULL, TEXT("Connection Accepted"), TEXT("Notice"), MB_OK); 
} 
L_INT DicomConnectExtExample(L_VOID) 
{ 
   L_UINT iHostPort = 0; 
   L_UINT iPeerPort = 104; 
   L_TCHAR szHostIP[200] = TEXT("");   // empty string means use local IP 
   L_TCHAR szPeerIP[200] = TEXT("fe80::18bd:81f:6b02:759f"); // valid IPv6 addres of computer to connect to 
   DICOMNETCALLBACK cb = {0}; 
   // start the network 
   L_INT nRet = L_DicomStartUp(); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
   // Create the Dicom Net object 
   HDICOMNET hNet = L_DicomCreateNet(NULL, DICOM_SECURE_NONE); 
   // Here we set the callbacks 
   // For simplicity, we set the OnConnect callback 
   // For a full example on how to set the callbacks, see the sample for L_DicomListen 
   memset(&cb, 0, sizeof(DICOMNETCALLBACK)); 
   cb.pfnConnect = (CONNECTCALLBACK)OnConnectCB; 
   cb.pUserData = NULL; 
   L_DicomSetCallback(hNet, &cb); 
   // Connect to a server 
   // Support both IPV4 and IPV6 addresses 
   return L_DicomConnectExt(hNet, szHostIP, iHostPort, szPeerIP, iPeerPort, DICOM_IPTYPE_IPV4_OR_IPV6); 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS DICOM C API Help