LDicomNet::Connect

#include "ltdic.h"

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

L_CHAR * pszHostAddress;

/* host IP address */

L_UINT nHostPort;

/* host port number */

L_CHAR * pszPeerAddress;

/* peer IP address */

L_UINT nPeerPort;

/* peer port number */

Connects an SCU to an SCP. This function is available in the Medical Suite 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

{   
   //LMyDicomNet is a class derived from LDicomNet
   //m_pDicomNet is a member variable declared as:
   //    LMyDicomNet *m_pDicomNet;
   int nRet;
   int iHostPort = 0;                     //Use first available port
   int iPeerPort = PEER_PORT;
   char *strHostIP = "";                //empty string means use local IP
   char *strPeerIP = "207.238.49.190";  //Put a valid IP addres of a computer to connect to
   
   //set the temporary file path
   m_pDicomNet = new LMyDicomNet("d:\\temp", DICOM_SECURE_NONE);
   
   //startup the network
   nRet = m_pDicomNet->StartUp();
   
   if (nRet == DICOM_SUCCESS)
      AfxMessageBox("StartUp() Successful");
   else
      AfxMessageBox("StartUp() Failed");
   
   //connect to a server
   nRet = m_pDicomNet->Connect(strHostIP, iHostPort, strPeerIP, iPeerPort);
   
   //Display "Connect" in window pane
   this->SetWindowText("Connect");
   m_nStatus = STATUS_CLIENT;
}