I hope to clarify my understanding of MINA through examples.
I have a logging server and 100 clients. Each client sends a request to the server to log its information and the server processes the client's request by reading from its buffer. In this case, the SocketAcceptor plays the server and the SocketConnector plays the client. The SocketAcceptor listens on a particular port and once a connection is opened, it waits for the client to write relevant data, server reads it and prints it onto the console. Mina should work like a dream for this situation.
I have an application that does asynchronous reads and writes to devices (e.g. PLC) via ethernet/ip. There is a selectable channel tied to the device's IP address and the read/writes are initiated by the application which sends a request to the device. The device on receiving a request, sends a response automatically which is read by the application. The request/response formats are based on existing standards adopted by device vendors (CIP protocol).
So, communication with the device happens using a SelectableChannel (tied to the device’s IP address) which registers with a selector for read/write interest and when data has to be read from a device, a read event is pushed onto a queue, selector is woken up and read happens. There could be many reads happening at the same time or alternate reads and writes in a totally ad-hoc fashion. Is MINA a good choice for this scenario where you send and receive bytes of data to devices?
Sent: Monday, July 18, 2005 7:14 PM
To: Bharath Sundararaman;
Subject: Re: [MINA] and readiness selection
2005/7/18, Bharath Sundararaman <Bharath.Sundararaman@starthis.com>:
I'm trying to talk to a PLC using MINA via Ethernet/IP protocol. Basically, I need to have a Channel (eg. SocketChannel) which registers with a Selector (called via SocketAcceptor). The Channel is tied to the PLC's IP address and it performs the reads/writes from the PLC.
I tried to use SocketAcceptor and SocketConnector to achieve this but the SocketConnector cannot use the 'Session' object which is returned by the 'connect' method to write onto the session. In other words, the SocketConnector (or the channel in my case) cannot initiate the read/write. I am trying to just link the PLC to a channel which registers with a selector via MINA.
You could write messages on a 'sessionOpened' event. If any data
is read from SocketConnector, you'll get notified by a 'dataRead (or
messageReceived if you're using Protocol layer)' event.
what we call human nature is actually human habit