net.wimpi.modbus.net
Class ModbusTCPListener

java.lang.Object
  extended by net.wimpi.modbus.net.ModbusTCPListener
All Implemented Interfaces:
Runnable

public class ModbusTCPListener
extends Object
implements Runnable

Class that implements a ModbusTCPListener.
If listening, it accepts incoming requests passing them on to be handled.

Version:
1.2 (@date@)
Author:
Dieter Wimberger

Field Summary
private static int c_RequestCounter
           
private  InetAddress m_Address
           
private  int m_FloodProtection
           
private  Thread m_Listener
           
private  boolean m_Listening
           
private  int m_Port
           
private  ServerSocket m_ServerSocket
           
private  ThreadPool m_ThreadPool
           
private static int REQUESTS_TOGC
           
 
Constructor Summary
ModbusTCPListener(int poolsize)
          Constructs a ModbusTCPListener instance.
ModbusTCPListener(int poolsize, InetAddress addr)
          Constructs a ModbusTCPListener instance.
 
Method Summary
private  void count()
           
 boolean isListening()
          Tests if this ModbusTCPListener is listening and accepting incoming connections.
 void run()
          Accepts incoming connections and handles then with TCPConnectionHandler instances.
 void setAddress(InetAddress addr)
          Sets the address of the interface to be listened to.
 void setPort(int port)
          Sets the port to be listened to.
 void start()
          Starts this ModbusTCPListener.
 void stop()
          Stops this ModbusTCPListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c_RequestCounter

private static int c_RequestCounter

m_ServerSocket

private ServerSocket m_ServerSocket

m_ThreadPool

private ThreadPool m_ThreadPool

m_Listener

private Thread m_Listener

m_Port

private int m_Port

m_FloodProtection

private int m_FloodProtection

m_Listening

private boolean m_Listening

m_Address

private InetAddress m_Address

REQUESTS_TOGC

private static final int REQUESTS_TOGC
See Also:
Constant Field Values
Constructor Detail

ModbusTCPListener

public ModbusTCPListener(int poolsize)
Constructs a ModbusTCPListener instance.

Parameters:
poolsize - the size of the ThreadPool used to handle incoming requests.

ModbusTCPListener

public ModbusTCPListener(int poolsize,
                         InetAddress addr)
Constructs a ModbusTCPListener instance.

Parameters:
poolsize - the size of the ThreadPool used to handle incoming requests.
addr - the interface to use for listening.
Method Detail

setPort

public void setPort(int port)
Sets the port to be listened to.

Parameters:
port - the number of the IP port as int.

setAddress

public void setAddress(InetAddress addr)
Sets the address of the interface to be listened to.

Parameters:
addr - an InetAddress instance.

start

public void start()
Starts this ModbusTCPListener.


stop

public void stop()
Stops this ModbusTCPListener.


run

public void run()
Accepts incoming connections and handles then with TCPConnectionHandler instances.

Specified by:
run in interface Runnable

isListening

public boolean isListening()
Tests if this ModbusTCPListener is listening and accepting incoming connections.

Returns:
true if listening (and accepting incoming connections), false otherwise.

count

private void count()


Copyright © 2012. All Rights Reserved.