L_DicomSetSocketOptions

#include "ltdic.h"

L_LTDIC_API L_INT EXT_FUNCTION L_DicomSetSocketOptions(hNet, pOptions)

Sets the socket options used in an hNet network handle.

Parameters

HDICOMNET hNet

A DICOM Network handle. This is the handle returned from the L_DicomCreateNet function

pDICOMSOCKETOPTIONS pOptions

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

Returns

Value Meaning
DICOM_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 the L_DicomConnect function on an hNet network handle. Internally, the socket is created when calling the L_DicomConnect function. Therefore, the L_DicomSetSocketOptions function should be called before calling the L_DicomConnect function.

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

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

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 DicomSetSocketOptionsExample(L_VOID) 
{ 
   L_INT nRet = DICOM_SUCCESS; 
   L_UINT iHostPort = 0; 
   L_UINT iPeerPort = 104; 
   L_TCHAR szHostIP[200] = {0}; 
   L_TCHAR szPeerIP[200] = {0}; 
   HDICOMNET hNet = 0; 
 
   // start the network 
   nRet = L_DicomStartUp(); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   // set the temporary file path 
   hNet = L_DicomCreateNet(MAKE_IMAGE_PATH(TEXT("")), DICOM_SECURE_NONE); 
 
   lstrcpy(szHostIP, TEXT("")); // empty string means use local IP  
   lstrcpy(szPeerIP, TEXT("207.238.49.195")); // valid IP address of computer to connect to 
 
   // Set the socket options before calling Connect 
   DICOMSOCKETOPTIONS socketOptions = {0}; 
   socketOptions.uStructSize = sizeof(DICOMSOCKETOPTIONS); 
   nRet = L_DicomGetDefaultSocketOptions(hNet, &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 = L_DicomSetSocketOptions(hNet, &socketOptions); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   // Display the new socket options 
   DICOMSOCKETOPTIONS newSocketOptions = {0}; 
   newSocketOptions.uStructSize = sizeof(DICOMSOCKETOPTIONS); 
   nRet = L_DicomGetSocketOptions(hNet, &newSocketOptions, sizeof(DICOMSOCKETOPTIONS)); 
   DisplaySocketOptions(&newSocketOptions); 
 
 
   // connect to a server 
   nRet = L_DicomConnect(hNet, szHostIP, iHostPort, szPeerIP, iPeerPort); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   // ... 
   // ... 
   // ... 
 
   L_DicomClose(hNet); 
   L_DicomFreeNet(hNet); 
 
   return nRet; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.