SendAsync / ReceiveAsync

Monkey Forums/Monkey Programming/SendAsync / ReceiveAsync

cgrossi(Posted 2016) [#1]
Hello,

Does anyone have an "workable" sample of SendAsync and ReceiveAsync? I'm trying to make a simple message exchange and can't make it work. I want something very simple. Just the client send/receive a message to/from the server and vice-versa.


ImmutableOctet(SKNG)(Posted 2016) [#2]
I literally posted two examples, and a fully working module, with how to use it. Pass a 'DataBuffer', and don't mess with it until you get the 'OnReceiveComplete' callback. It'll call 'Receive' on a different thread, which means it won't stop the program while it's running.

I'm done. If someone else wants to give him an example, go ahead.


PixelPaladin(Posted 2016) [#3]
I don't think it will get any simpler. The examples from ImmutableOctet and these that come with monkey (<monkey_folder>/bananas/mak/echoserver_tcp and /echoserver_udp) already are relatively 'simple'. To get a better understanding of what is going on, you maybe should have a look at the posix socket api like Sicilica recommended.


Xaron(Posted 2016) [#4]
Or just read something about networking in general to get what's going on behind the scenes. Networking is one of the most complex things one could imagine. Even after more than 15 years of programming I still have some huge respect regarding that topic.

Regarding a working example. There is this echo tcp server/client example in the bananas folder. Can't be simpler actually. But if you want to do some serious networking use that module from ImmutableOctet.


Paul - Taiphoz(Posted 2016) [#5]
Networking is not a simple subject unfortunately there is a lot of complexity inherent to the act of creating a client server relationship, even something that sounds simple like sending a message and getting any messages from a server can actually be complex.