Le 10/17/12 3:04 PM, Dever, Jeffrey a écrit :
We have a connection that is currently TCP but are changing it to UDP on both
the client and server sides. It looks like we could just change the
SocketConnector to a DatagramConnector and same for the Acceptor and use all
the same IoHandler, Decoder etc classes.
This does seem to work, but I don't get some of the callbacks when I expect
them. In particular, when I build both endpoints, I don't get a
sessionCreated() called on the server when a client connects. Only when the
client sends data does that function get called from the IoHandler. In my case
the client will never send data, only the server does, but the server can't
send data since I don't have a session objects.
Advice would be helpful.
Hi Jeffrey,
there is no way for the server to 'know' that the client connects. The
connection is just used to store the IP in order to check that the
incoming messages are to be handled or not (you can perfectly receive
some messages you don't wnat to get, for instance when some broadcast
messages are sent).
In other word, it's plain normal that your server does not call the
SessionCreated event. The only way to do that is to send a message,
which will trigger the session creation, session that will remain active
as soon as some other messages are being received before it becomes idle
- and get discarded.
The way the UDP server handles session is somehow really different in
UDP compared to TCP. It's also du to he fact that UDP is a
connectionless protocol, when TCP is connected.
I don't see any simple way to send a direct message from the server to
the client when you don't have the client IP address...
May be it would be a good extension to MINA to add a way to send a
message to a session which does not -yet- exist, assuming that there is
no real difference between a client and a server when it comes to UDP
protocol handling ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com