Asynchronous code help...

A

adrian

Hi all,

I am trying to programming a server to do some function
calls in a P2P. One of this functions return a String but
in asynchronous way.Can you give some code guidelines of
how to cope with asynchronous logic? I mean how to catch
this string(message) that returned from the function.

My protocol:
The client asks the server for some data,server don't know
and ask P2P,server "take" that reply and forward it to client.

Thank you,
Adrian.
 
M

Matt Humphrey

adrian said:
Hi all,

I am trying to programming a server to do some function
calls in a P2P. One of this functions return a String but
in asynchronous way.Can you give some code guidelines of
how to cope with asynchronous logic? I mean how to catch
this string(message) that returned from the function.

My protocol:
The client asks the server for some data,server don't know
and ask P2P,server "take" that reply and forward it to client.

An easy approach is for the server to make an immediate answer that contains
a task id--some kind of identifier that the client can later user to poll
for results. Periodically the client can ask if the answer is ready and get
back either that it's not ready or that it is and here's the answer.

Converting a pure client/server request system into one that permits
asynchonous replies can be very tricky, particularly because the reply to
any ordinary request from client to server must be distinguished from an
incoming asynchronous notice. It's doable, though.

Cheers,
Matt Humphrey (e-mail address removed) http://www.iviz.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top