LDicomNet::Connect

#include "ltdic.h"

L_INT LDicomNet::Connect(pszHostAddress, nHostPort, pszPeerAddress, nPeerPort)

L_TCHAR * pszHostAddress;

/* host IP address */

L_UINT nHostPort;

/* host port number */

L_TCHAR * pszPeerAddress;

/* peer IP address */

L_UINT nPeerPort;

/* peer port number */

Connects an SCU to an SCP. This function is available in the PACS Imaging Toolkit.

Parameter

Description

pszHostAddress

Character string that contains the IP address of the host computer (the SCU's address).

nHostPort

Port number of the host (the SCU's port).

pszPeerAddress

Character string that contains the IP address of the peer computer to which to connect (the SCP's address).

nPeerPort

Port number of the peer computer to which to connect (the SCP's port).

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.

To connect to an SCP as an SCU, 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 SCP, you must first create a DICOM Network object using LDicomNet::LDicomNet. Then call LDicomNet::Listen to listen for incoming connection requests.

When an SCU calls this function, it generates an LDicomNet::OnAccept function call on the SCP.

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:

LDicomNet::LDicomNet, LDicomNet::StartUp, LDicomNet::Listen

Topics:

Working with DICOM Network Connections

Example

// define needed variables
#define PEER_PORT 104
#define STATUS_NONE     0
#define STATUS_SERVER   1
#define STATUS_CLIENT   2
L_INT LDicomNet_ConnectExample(CWnd hWnd, LMyDicomNet *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(TEXT("d:\\temp"), DICOM_SECURE_NONE);
   //startup the network
   nRet = m_pDicomNet->StartUp();
   if (nRet == DICOM_SUCCESS)
      AfxMessageBox(TEXT("StartUp() Successful"));
   else
   {
      AfxMessageBox(TEXT("StartUp() Failed"));
      return nRet;
   }
   //connect to a server
   nRet = m_pDicomNet->Connect(strHostIP, iHostPort, strPeerIP, iPeerPort);
//Display "Connect" in window pane
   hWnd.SetWindowText(TEXT("Connect"));
   *nStatus = STATUS_CLIENT;
   return DICOM_SUCCESS;
}