Hello everyone,
Let me tell you about my program. I have a C++ Client, that connects to a C# DLL. The C# Dll communicate with a distant Java Server ( for the moment and testing purpose It's local )
My C# DLL communicate with my Java Server through a Socket.
First of all, my C++ Client communicate #1 with my C# DLL. Also my C# DLL is able to connect with my Java Server throught the socket.
the problem is, I send in my C# DLL an array of bytes to my Java Server. But the DataInputStream in my Java server seems to not be able to retrieve what I'v sent. What's wrong
This is my C# DLL in one of my function (btw sorry but some names are french :( But in that case i believe they aren't important )
Socket ServeurSocket = null;
public int GetNombreAvions()
{
IPHostEntry lipa = Dns.Resolve("localhost");
IPEndPoint lep = new IPEndPoint(lipa.AddressList[0], 5555);
ServeurSocket = new Socket(lep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
byte[] msg = Encoding.ASCII.GetBytes("CMD.NOMBRE");
ServeurSocket.Connect(lep);
if(ServeurSocket.Connected)
{
ServeurSocket.Send(msg, msg.Length, SocketFlags.None);
//Wait Return Message
byte[] MsgReturn = new byte[1024];
ServeurSocket.Receive(MsgReturn,0, ServeurSocket.Available, SocketFlags.None);
return int.Parse(Encoding.ASCII.GetString(MsgReturn));
}
return -1;
}
And Heres My Java Server objet and where i retrieve the data sent.
Socket socket;
ServerSocket socketServeur;
DataInputStream reader;
PrintWriter writer;
writer = new PrintWriter(
new OutputStreamWriter(
socket.getOutputStream() ), true );
reader = new DataInputStream(socket.getInputStream());
System.out.println( "Client connecte" );
System.out.println(reader.readLine());
If you need any additional source code, tell me so and I'll put it. Thank for your help.