org.dcm4che2.net
Class NetworkConnection

java.lang.Object
  extended by org.dcm4che2.net.NetworkConnection

public class NetworkConnection
extends java.lang.Object

A DICOM Part 15, Annex H compliant class, NetworkConnection encapsulates the properties associated with a connection to a TCP/IP network.

The network connection describes one TCP port on one network device. This can be used for a TCP connection over which a DICOM association can be negotiated with one or more Network AEs. It specifies 8 the hostname and TCP port number. A network connection may support multiple Network AEs. The Network AE selection takes place during association negotiation based on the called and calling AE-titles.

Since:
Nov 24, 2005
Version:
$Revision: 13931 $ $Date: 2008-04-01 05:03:40 -0500 (Tue, 01 Apr 2008) $
Author:
gunter zeilinger(gunterze@gmail.com)

Field Summary
static int DEFAULT
           
static int ONLY_ACTIVE
           
protected  java.net.ServerSocket server
           
 
Constructor Summary
NetworkConnection()
           
 
Method Summary
 void bind(java.util.concurrent.Executor executor)
          Bind this network connection to a TCP port and start a server socket accept loop.
protected  boolean checkConnection(java.net.Socket s)
          Check the incoming socket connection against the limitations set up for this Network Connection.
 boolean checkConnectionCountWithinLimit()
          Check to see if the specified number of associations has been exceeded.
 java.net.Socket connect(NetworkConnection peerConfig)
          Create a socket as an SCU and connect to a peer network connection (the SCP).
protected  java.net.ServerSocket createTLSServerSocket()
           
protected  java.net.Socket createTLSSocket()
           
protected  void decListenerConnectionCount()
          Decrement the number of active associations.
 void disableSSLv2Hello()
           
 void enableSSLv2Hello()
           
 int getAcceptTimeout()
           
 int getBacklog()
           
 java.lang.String getCommonName()
          An arbitrary name for the Network Connections object.
 int getConnectTimeout()
           
 Device getDevice()
          Get the Device object that this Network Connection belongs to.
 java.util.List<java.lang.String> getExcludeConnectionsFrom()
          Get a list of IP addresses from which we should ignore connections.
 java.lang.String getHostname()
          This is the DNS name for this particular connection.
 int getMaxScpAssociations()
          Get the maximum number of incoming associations that this Network Connection will allow.
 int getPort()
          The TCP port that the AE is listening on.
 int getReceiveBufferSize()
          Get the SO_RCVBUF socket value in KB.
 int getReleaseTimeout()
          Timeout in ms for receiving A-RELEASE-RP, 5000 by default.
 int getRequestTimeout()
          Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default
 int getSendBufferSize()
          Get the SO_SNDBUF socket option value in KB,
 java.net.ServerSocket getServer()
          Returns server socket associated with this Network Connection, bound to the TCP port, listening for connect requests.
 int getSocketCloseDelay()
          Delay in ms for Socket close after sending A-ABORT, 50ms by default.
 java.lang.String[] getTlsCipherSuite()
          The TLS CipherSuites that are supported on this particular connection.
 java.lang.String[] getTlsProtocol()
           
protected  void incListenerConnectionCount()
          Increment the number of active associations.
 boolean isInstalled()
          True if the Network Connection is installed on the network.
 boolean isListening()
           
 boolean isTcpNoDelay()
          Determine if this network connection is using Nagle's algorithm as part of its network communication.
 boolean isTLS()
           
 boolean isTlsNeedClientAuth()
           
 void setAcceptTimeout(int timeout)
           
 void setBacklog(int backlog)
           
 void setCommonName(java.lang.String name)
          An arbitrary name for the Network Connections object.
 void setConnectTimeout(int timeout)
           
 void setExcludeConnectionsFrom(java.util.List<java.lang.String> excludeConnectionsFrom)
          Set a list of IP addresses from which we should ignore connections.
 void setHostname(java.lang.String hostname)
          This is the DNS name for this particular connection.
 void setInstalled(boolean installed)
          True if the Network Connection is installed on the network.
 void setMaxScpAssociations(int maxListenerAssociations)
          Set the maximum number of incoming associations that this Network Connection will allow.
 void setPort(int port)
          The TCP port that the AE is listening on.
 void setReceiveBufferSize(int size)
          Set the SO_RCVBUF socket option to specified value in KB.
 void setReleaseTimeout(int timeout)
          Timeout in ms for receiving A-RELEASE-RP, 5000 by default.
 void setRequestTimeout(int timeout)
          Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default
 void setSendBufferSize(int size)
          Set the SO_SNDBUF socket option to specified value in KB,
 void setSocketCloseDelay(int delay)
          Delay in ms for Socket close after sending A-ABORT, 50ms by default.
protected  void setSocketOptions(java.net.Socket s)
          Set options on a socket that was either just accepted (if this network connection is an SCP), or just created (if this network connection is an SCU).
 void setTcpNoDelay(boolean tcpNoDelay)
          Set whether or not this network connection should use Nagle's algorithm as part of its network communication.
 void setTls3DES_EDE_CBC()
           
 void setTlsAES_128_CBC()
           
 void setTlsCipherSuite(java.lang.String[] tlsCipherSuite)
          The TLS CipherSuites that are supported on this particular connection.
 void setTlsNeedClientAuth(boolean tlsNeedClientAuth)
           
 void setTlsProtocol(java.lang.String[] tlsProtocol)
           
 void setTlsWithoutEncyrption()
           
 java.lang.String toString()
           
 void unbind()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
See Also:
Constant Field Values

ONLY_ACTIVE

public static final int ONLY_ACTIVE
See Also:
Constant Field Values

server

protected java.net.ServerSocket server
Constructor Detail

NetworkConnection

public NetworkConnection()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getDevice

public Device getDevice()
Get the Device object that this Network Connection belongs to.

Returns:
Device

getHostname

public java.lang.String getHostname()
This is the DNS name for this particular connection. This is used to obtain the current IP address for connections. Hostname must be sufficiently qualified to be unambiguous for any client DNS user.

Returns:
A String containing the host name.

setHostname

public void setHostname(java.lang.String hostname)
This is the DNS name for this particular connection. This is used to obtain the current IP address for connections. Hostname must be sufficiently qualified to be unambiguous for any client DNS user.

Parameters:
hostname - A String containing the host name.

getCommonName

public java.lang.String getCommonName()
An arbitrary name for the Network Connections object. Can be a meaningful name or any unique sequence of characters.

Returns:
A String containing the name.

setCommonName

public void setCommonName(java.lang.String name)
An arbitrary name for the Network Connections object. Can be a meaningful name or any unique sequence of characters.

Parameters:
name - A String containing the name.

getPort

public int getPort()
The TCP port that the AE is listening on. (This may be missing for a network connection that only initiates associations.)

Returns:
An int containing the port number.

setPort

public void setPort(int port)
The TCP port that the AE is listening on. A valid port value is between 0 and 65535, or ONLY_ACTIVE for network connection that only initiates associations. A port number of zero will let the system pick up an ephemeral port.

Parameters:
port - The port number

getTlsCipherSuite

public java.lang.String[] getTlsCipherSuite()
The TLS CipherSuites that are supported on this particular connection. TLS CipherSuites shall be described using an RFC-2246 string representation (e.g. 'SSL_RSA_WITH_3DES_EDE_CBC_SHA')

Returns:
A String array containing the supported cipher suites

setTlsCipherSuite

public void setTlsCipherSuite(java.lang.String[] tlsCipherSuite)
The TLS CipherSuites that are supported on this particular connection. TLS CipherSuites shall be described using an RFC-2246 string representation (e.g. 'SSL_RSA_WITH_3DES_EDE_CBC_SHA')

Parameters:
tlsCipherSuite - A String array containing the supported cipher suites

setTlsWithoutEncyrption

public void setTlsWithoutEncyrption()

setTls3DES_EDE_CBC

public void setTls3DES_EDE_CBC()

setTlsAES_128_CBC

public void setTlsAES_128_CBC()

isInstalled

public boolean isInstalled()
True if the Network Connection is installed on the network. If not present, information about the installed status of the Network Connection is inherited from the device.

Returns:
boolean True if the NetworkConnection is installed on the network.

setInstalled

public void setInstalled(boolean installed)
True if the Network Connection is installed on the network. If not present, information about the installed status of the Network Connection is inherited from the device.

Parameters:
installed - True if the NetworkConnection is installed on the network.

isListening

public boolean isListening()

isTLS

public boolean isTLS()

getBacklog

public int getBacklog()

setBacklog

public void setBacklog(int backlog)

getAcceptTimeout

public int getAcceptTimeout()

setAcceptTimeout

public void setAcceptTimeout(int timeout)

getConnectTimeout

public int getConnectTimeout()

setConnectTimeout

public void setConnectTimeout(int timeout)

getRequestTimeout

public int getRequestTimeout()
Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default

Parameters:
An - int value containing the milliseconds.

setRequestTimeout

public void setRequestTimeout(int timeout)
Timeout in ms for receiving A-ASSOCIATE-RQ, 5000 by default

Parameters:
timeout - An int value containing the milliseconds.

getReleaseTimeout

public int getReleaseTimeout()
Timeout in ms for receiving A-RELEASE-RP, 5000 by default.

Returns:
An int value containing the milliseconds.

setReleaseTimeout

public void setReleaseTimeout(int timeout)
Timeout in ms for receiving A-RELEASE-RP, 5000 by default.

Parameters:
timeout - An int value containing the milliseconds.

getSocketCloseDelay

public int getSocketCloseDelay()
Delay in ms for Socket close after sending A-ABORT, 50ms by default.

Returns:
An int value containing the milliseconds.

setSocketCloseDelay

public void setSocketCloseDelay(int delay)
Delay in ms for Socket close after sending A-ABORT, 50ms by default.

Parameters:
delay - An int value containing the milliseconds.

getReceiveBufferSize

public int getReceiveBufferSize()
Get the SO_RCVBUF socket value in KB.

Returns:
An int value containing the buffer size in KB.

setReceiveBufferSize

public void setReceiveBufferSize(int size)
Set the SO_RCVBUF socket option to specified value in KB.

Parameters:
bufferSize - An int value containing the buffer size in KB.

getSendBufferSize

public int getSendBufferSize()
Get the SO_SNDBUF socket option value in KB,

Returns:
An int value containing the buffer size in KB.

setSendBufferSize

public void setSendBufferSize(int size)
Set the SO_SNDBUF socket option to specified value in KB,

Parameters:
bufferSize - An int value containing the buffer size in KB.

isTcpNoDelay

public boolean isTcpNoDelay()
Determine if this network connection is using Nagle's algorithm as part of its network communication.

Returns:
boolean True if TCP no delay (disable Nagle's algorithm) is used.

setTcpNoDelay

public void setTcpNoDelay(boolean tcpNoDelay)
Set whether or not this network connection should use Nagle's algorithm as part of its network communication.

Parameters:
tcpNoDelay - boolean True if TCP no delay (disable Nagle's algorithm) should be used.

isTlsNeedClientAuth

public boolean isTlsNeedClientAuth()

setTlsNeedClientAuth

public void setTlsNeedClientAuth(boolean tlsNeedClientAuth)

getTlsProtocol

public java.lang.String[] getTlsProtocol()

setTlsProtocol

public void setTlsProtocol(java.lang.String[] tlsProtocol)

enableSSLv2Hello

public void enableSSLv2Hello()

disableSSLv2Hello

public void disableSSLv2Hello()

getServer

public java.net.ServerSocket getServer()
Returns server socket associated with this Network Connection, bound to the TCP port, listening for connect requests. Returns null if this network connection only initiates associations or was not yet bound by bind(java.util.concurrent.Executor).

Returns:
server socket associated with this Network Connection or null

connect

public java.net.Socket connect(NetworkConnection peerConfig)
                        throws java.io.IOException
Create a socket as an SCU and connect to a peer network connection (the SCP).

Parameters:
peerConfig - The peer NetworkConnection object that this network connection is connecting to.
Returns:
Socket The created socket object.
Throws:
java.io.IOException - If the connection cannot be made due to network IO reasons.

setSocketOptions

protected void setSocketOptions(java.net.Socket s)
                         throws java.net.SocketException
Set options on a socket that was either just accepted (if this network connection is an SCP), or just created (if this network connection is an SCU).

Parameters:
s - The Socket object.
Throws:
java.net.SocketException - If the options cannot be set on the socket.

bind

public void bind(java.util.concurrent.Executor executor)
          throws java.io.IOException
Bind this network connection to a TCP port and start a server socket accept loop.

Parameters:
executor - The Executor implementation that association threads should run within. The executor determines the threading model.
Throws:
java.io.IOException - If there is a problem with the network interaction.

checkConnection

protected boolean checkConnection(java.net.Socket s)
Check the incoming socket connection against the limitations set up for this Network Connection.

Parameters:
s - The socket connection.
Returns:
boolean True if association negotiation should proceed.

incListenerConnectionCount

protected void incListenerConnectionCount()
Increment the number of active associations.


decListenerConnectionCount

protected void decListenerConnectionCount()
Decrement the number of active associations.


checkConnectionCountWithinLimit

public boolean checkConnectionCountWithinLimit()
Check to see if the specified number of associations has been exceeded.

Parameters:
maxAssociations - An int containing the maximum number of associations allowed.
Returns:
boolean True if the max association count has not been exceeded.

unbind

public void unbind()

createTLSSocket

protected java.net.Socket createTLSSocket()
                                   throws java.io.IOException
Throws:
java.io.IOException

createTLSServerSocket

protected java.net.ServerSocket createTLSServerSocket()
                                               throws java.io.IOException
Throws:
java.io.IOException

getExcludeConnectionsFrom

public java.util.List<java.lang.String> getExcludeConnectionsFrom()
Get a list of IP addresses from which we should ignore connections. Useful in an environment that utilizes a load balancer. In the case of a TCP ping from a load balancing switch, we don't want to spin off a new thread and try to negotiate an association.

Returns:
Returns the list of IP addresses which should be ignored.

setExcludeConnectionsFrom

public void setExcludeConnectionsFrom(java.util.List<java.lang.String> excludeConnectionsFrom)
Set a list of IP addresses from which we should ignore connections. Useful in an environment that utilizes a load balancer. In the case of a TCP ping from a load balancing switch, we don't want to spin off a new thread and try to negotiate an association.

Parameters:
excludeConnectionsFrom - the list of IP addresses which should be ignored.

getMaxScpAssociations

public int getMaxScpAssociations()
Get the maximum number of incoming associations that this Network Connection will allow.

Returns:
int An int which defines the max associations.

setMaxScpAssociations

public void setMaxScpAssociations(int maxListenerAssociations)
Set the maximum number of incoming associations that this Network Connection will allow.

Parameters:
maxScpAssociations - An int which defines the max associations.


Copyright © 2011 dcm4che. All Rights Reserved.