0

i have created a metro style datagram server and a client using Windows.Networking.Sockets. i am doing code in c++

Than i tried to connect and send data from client to server.

but the problem i am facing is that, as windows metro application is totally asynchronous,my app starts to send data before connection being completed.

i want an approach through which my send function will send data after the connection completed.

msdn has provided a sample code for client server but they use a button to send data which takes time to operate meanwhile the connection is completed.Thats why the application runs well.

but i am trying to do client server communication in the main code without using send Button.

1 Answers1

0

Making some assumptions here b/c you didn't provide any code, but you should use the continuation of your DatagramSocket.ConnectAsync create_task. If you put the send data in the task::then, you will not have a problem with the async nature of the call. See this article on dealing with async in C++ Windows 8 apps. Lots of great examples here as well.

JP Alioto
  • 44,864
  • 6
  • 88
  • 112