Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS DICOM C++ Class Library Help

LDicomNet::SetSocketOptions

Show in webframe

#include "ltdic.h"

L_INT LDicomNet::SetSocketOptions(pOptions)

pDICOMSOCKETOPTIONS pOptions;

/* pointer to a structure */

Sets the socket options used in a LDicomNet object. This feature is available in version 16 or higher.

Parameter

Description

pOptions

Pointer to a structure that contains the options to used when creating a socket for DICOM communication.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This method is used to set options in the socket that will be created when calling LDicomNet::Connect on a LDicomNet object. Internally, the socket is created when calling LDicomNet::Connect. Therefore, LDicomNet::SetSocketOptions method should be called before calling LDicomNet::Connect.

For more information about sockets, see the MSDN Winsock documentation.

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.

Platforms

Win32, x64

See Also

Functions:

LDicomNet::GetDefaultSocketOptions, LDicomNet::GetSocketOptions, Class Members

Topics:

Working with DICOM Network Connections

 

DICOM Network Connection: Creating a Network Connection

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_VOID DisplaySocketOptions(pDICOMSOCKETOPTIONS pOptions)
{
   L_TCHAR szMsg[200] = {0};
   if (!pOptions)
      return;
   wsprintf(szMsg, TEXT("Socket Options:\n\tnSendBufferSize: %d\n\tnReceiveBufferSize: %d\n\tbNoDelay: %d"),
      pOptions->nSendBufferSize,
      pOptions->nReceiveBufferSize,
      pOptions->bNoDelay);
   MessageBox(NULL, szMsg, TEXT("Socket Options"), MB_OK);
}
L_INT LDicomNet_SetSocketOptionsExample()
{
   L_INT       nRet      = DICOM_SUCCESS;
   L_INT       iHostPort = 0;                      //Use first available port
   L_INT       iPeerPort = 104;
   L_TCHAR *   pszHostIP = TEXT("");                //empty string means use local IP
   L_TCHAR *   pszPeerIP = 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
   LMyDicomNet *pDicomNet = new LMyDicomNet(MAKE_IMAGE_PATH(TEXT("temp")), DICOM_SECURE_NONE);
   if (pDicomNet == NULL)
      return DICOM_ERROR_MEMORY;
   //startup the network
   nRet = pDicomNet->StartUp();
   if (nRet != DICOM_SUCCESS)
      return nRet;
   // Set the socket options before calling Connect
   DICOMSOCKETOPTIONS socketOptions = {0};
   socketOptions.uStructSize = sizeof(DICOMSOCKETOPTIONS);
   nRet = pDicomNet->GetDefaultSocketOptions(&socketOptions, sizeof(DICOMSOCKETOPTIONS));
   if (nRet != DICOM_SUCCESS)
      return nRet;
   // Display the default socket options
   DisplaySocketOptions(&socketOptions);
   socketOptions.nSendBufferSize = socketOptions.nSendBufferSize * 2;
   socketOptions.bNoDelay = !socketOptions.bNoDelay;
   nRet = pDicomNet->SetSocketOptions(&socketOptions);
   if (nRet != DICOM_SUCCESS)
      return nRet;
   // Display the new socket options
   DICOMSOCKETOPTIONS newSocketOptions = {0};
   newSocketOptions.uStructSize = sizeof(DICOMSOCKETOPTIONS);
   nRet = pDicomNet->GetSocketOptions(&newSocketOptions, sizeof(DICOMSOCKETOPTIONS));
   DisplaySocketOptions(&newSocketOptions);
   //connect to a server using the new socket options
   nRet = pDicomNet->Connect(pszHostIP, iHostPort, pszPeerIP, iPeerPort);
   if (nRet != DICOM_SUCCESS)
      return nRet;
   // ...
   // ...
   // ...
   pDicomNet->Close();
   delete pDicomNet;
   return DICOM_SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.