I have two apps: one written in C# and another in C++. I want to communicate between them using UDP
While the communication C# -> C++ works fine, I can't make it work the other way (C++ -> C#).
On C++ end I use boost::asio, on C# the standard System.Net.Sockets.
C#: https://pastebin.com/eAP88j0P
C++ header: https://pastebin.com/6HYrtrey
C++ source: https://pastebin.com/Ksa4TKbY
Interface: https://pastebin.com/kiJZUzm2
I am using the Send(int) function to sent a 0 to the C# app. I get no exceptions, cod seems to be running fine, but I got no message on the onter end.
void UdpClient::Send(int i)
{
MFiflak fif;
fif.I = i;
boost::array<char, 4> buff = { fif.C[0], fif.C[1], fif.C[2], fif.C[3] };
std::cout << "Sending data to: " << _endpointOut->address().to_string() << " at port " << _endpointOut->port() << std::endl;
_socketOut->send_to(
boost::asio::buffer(buff), *(_endpointOut.get())
);
}
-
private void DoReceive(IAsyncResult result)
{
IPEndPoint ip = new IPEndPoint(IPAddress.Any, _incoming_port);
byte[] bytes = _server.EndReceive(result, ref ip);
MessageReceived?.Invoke(bytes);
if (!_stop) RunReceive();
}
Aucun commentaire:
Enregistrer un commentaire