Michael Bauroth wrote: > I would very interested in an explanation too (especially the > trafficmask and attachment handling). Hope you have the time to do so.
One problem with a tunneling proxy is that when a new client connects to the proxy you want to prevent the client from sending any data until the proxy has established a connection to the server. Otherwise you would have to buffer up messages in ClientToProxyIoHandler.messageReceived() until the proxy has conected to the server and then deliver the buffered messages. The session.setTrafficMask(TrafficMask.NONE) prevents any data to be read from the underlying socket. Since the example does this immediately as the session is created no buffering will be necessary (the OS will do the buffering so we don't have to). Once the proxy has established a connection to the server the traffic mask will be changed to allow for any waiting data to be delivered. Sessions can have an attachment. This is just something you can use to associate an object with a session. MINA will never read or care about the attachment. It's only there as a convenience for the developer using MINA. In the example the attachment is used to associate the client-to-proxy session with the proxy-to-server session and vice versa. Just let me know if you have any further questions! Regards, Niklas
