LEADTOOLS DICOM C++ Class Library Help > Classes and Member Functions > LDicomNet > LDicomNet Class Members > LDicomNet::Connect |
#include "ltdic.h"
L_INT LDicomNet::Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort)
L_INT LDicomNet::Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort, nIpType)
L_TCHAR * pszHostAddress; |
/* Called AE IP address */ |
L_UINT nHostPort; |
/* Called AE port number */ |
L_TCHAR * pszPeerAddress; |
/* Calling AE IP address */ |
L_UINT nPeerPort; |
/* Calling AE port number */ |
L_INT nIpType |
/* type of IP address */ |
Connects an Called AE to an Calling AE. This function is available in the PACS Imaging Toolkit.
Parameter |
Description |
|
pszHostAddress |
Character string that contains the IP address of the Called AE computer (the SCU's address). |
|
nHostPort |
Port number of the Called AE (the SCU's port). |
|
pszPeerAddress |
Character string that contains the IP address of the Calling AE computer to which to connect (the SCP's address). |
|
nPeerPort |
Port number of the Calling AE computer to which to connect (the SCP'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
0 |
SUCCESS |
>0 |
An error occurred. Refer to Return Codes. |
Comments
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 an Calling AE as an Called AE, you must first create a DICOM Network object using LDicomNet::LDicomNet. Then call LDicomNet::Connect to establish the connection.
To use your computer as an Calling AE, you must first create a DICOM Network object using LDicomNet::LDicomNet. Then call LDicomNet::Listen to listen for incoming connection requests.
When an Called AE calls this function, it generates an LDicomNet::OnAccept function call on the Calling AE.
The LDicomNet::Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort, nIpType) overload allows you to specify the 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 LDicomNet::Connect() 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:
Start a command prompt, and type the following command
ping 192.168.0.195
Note that the following are equivalent:
pDicomNet->Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort);
DicomNet->Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort, DICOM_IPTYPE_IPV4);
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 |
Win32, x64
See Also
Functions: |
|
Topics: |
Example
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName // define needed variables #define PEER_PORT 104 #define STATUS_NONE 0 #define STATUS_SERVER 1 #define STATUS_CLIENT 2 L_INT LDicomNet_ConnectExample(CWnd* pWnd, LDicomNet *m_pDicomNet, L_INT* nStatus) { L_INT nRet; L_INT iHostPort = 0; //Use first available port L_INT iPeerPort = PEER_PORT; L_TCHAR * strHostIP = TEXT(""); //empty string means use local IP TCHAR * strPeerIP = TEXT("207.238.49.190"); //Put a valid IP addres of a computer to connect to // LMyDicomNet is a class derived from LDicomNet //set the temporary file path m_pDicomNet = new LMyDicomNet(MAKE_IMAGE_PATH(TEXT("temp")), DICOM_SECURE_NONE); //startup the network nRet = m_pDicomNet->StartUp(); if (nRet == DICOM_SUCCESS) AfxMessageBox(TEXT("StartUp() Successfull")); else { AfxMessageBox(TEXT("StartUp() Failed")); return nRet; } //connect to a server nRet = m_pDicomNet->Connect(strHostIP, iHostPort, strPeerIP, iPeerPort); //Display "Connect" in window pane pWnd->SetWindowText(TEXT("Connect")); *nStatus = STATUS_CLIENT; return DICOM_SUCCESS; }