LDicomNet::SetSocketOptions

#include "ltdic.h"

L_INT LDicomNet::SetSocketOptions(pOptions)

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

Parameters

pDICOMSOCKETOPTIONS pOptions

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function 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 function should be called before calling LDicomNet::Connect.

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

Required DLLs and Libraries

Platforms

Win32, x64

See Also

Functions

Topics

Example

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 address of a computer to connect to 
 
   // LMyDicomNet is a class derived from LDicomNet 
   //set the temporary file path 
   LDicomNet *pDicomNet = new LDicomNet(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; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help