I guess we are on different page here

Lets dissect the problem first (couldn't draw it better in txt)

                      ServerSocket A (Receive)
     ClientSocket B (Sender)


---------------------------------------------------------------------------------------------------Server

                                 Send data
         receive data

                                 Client Socket GA
     ServerSocket GB
                                                              GPS Device


So the understanding is, GPS device always send the data to Socket A,
whereas it received data from Server
on a different Socket. I hope this is the situation we are talking about

Now lets walk the scenario

GPS Devide -> ClientSocket GA -> ServerSocket A -> IOhandler -> Put
message in Hashtable -> call clientSocket B -> send Data

--> serverScoket GB -> GPS devide does some processing -> send data ->
client Socket GA

Now the cycle is same.

In you IoHandler, you just need to check if its a response, if yes,
then do the processing and remove your data from hashtable. If its
request (whatever you call it), put the data in map, and initiate
client to send a command

You don't need to worry about Threads. Just see that UDP is
unreliable, so that you need to take care of in you app.

If it doesn't help, please add to the missing pieces and will be glad
to help. Please note that you need an impure Server meaning Server
with Client functionality as well. Don't worry, its used many a times.

thanks
ashish

On Tue, Sep 1, 2009 at 12:02 AM, Rodrigo Hernandez
Soares<[email protected]> wrote:
> Thanks for the answer.
>
> My doubt is: when the NioDatagramConnector is created, how can I associate
> this connector with the port setted in the NIO Acceptor? The tracker device
> sends the responses of all the commands to the same NIO Acceptor (static
> address and port). Is the Connector able to multiplex the correct response
> of a command to the correct trhead through the NIO Acceptor?
>
> On Mon, Aug 31, 2009 at 10:43 AM, Ashish <[email protected]> wrote:
>
>> Hmm, have a look at the UDP server example.
>>
>> Don't think this is a problem. AFAIK.
>>
>> If I got it correctly, I would have something like this
>>
>> Create  an NIO Acceptor (say A1)
>> Create a NIO Connector (say C1)
>> receive data on A1
>> send a command via C1
>> maintain that command state in some cache or hashtable
>> receive response via A1
>> in the IOHandler, get the data from cache/hashtable
>>
>> Hope it helps. Correct me if I have got the problem incorrectly
>>
>> thanks
>> ashish
>>
>> On Mon, Aug 31, 2009 at 7:00 PM, Rodrigo Hernandez
>> Soares<[email protected]> wrote:
>> > Hello.
>> > After all, please, forgive my english.
>> >
>> > I have this scenario:
>> >
>> > A server with a DatagramSocket, which receives periodic positioning
>> messages
>> > (byte[]) from a gps tracker device (udp + gprs communication).
>> > Eventually i need to send commands (byte[]) to the device. To perform
>> this
>> > task, i create a new DatagramSocket in the server. The problem is:
>> > the response to my command arrives through the other DatagramSocket,
>> instead
>> > of arrives through the new Socket.
>> >
>> > That problem, in a multi-thread scenario, prevents the response to
>> arrives
>> > to the correct sender (thread).
>> >
>> > Can MINA solve my problem?
>> >
>> > Thanks!
>> >
>>
>>
>>
>> --
>> thanks
>> ashish
>>
>> Blog: http://www.ashishpaliwal.com/blog
>> My Photo Galleries: http://www.pbase.com/ashishpaliwal
>>
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Reply via email to