K
Krzysztof Paz
Hi,
There is a Java (SUN 1.4) server which using Object Input/Output Streams at
SSL/Socket to communicate with Java clients.
Now there is a request for making C# Client for this server also.
SSL layer could be done with Org.Mentalis.Security.dll from seclib-1.0
Mentalis package - its fine...
But, threre is a problem:
How to properly communicate from C# language to Java.ObjectInputStream -
cause I've tried many times, and always get the Java exception about wrong
stream header.
I've tought about using such code:
....
Connection = new SecureSocket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp, options);
Connection.Connect(new IPEndPoint(Dns.Resolve(server).AddressList[0],
int.Parse(port)));
Send("GET_SERVER_VERSION.CSHARP.SSL.MENTALIS\r\n", "UNKNOWN HEADER");
....
protected void Send(string data, Header header) {
System.IO.MemoryStream memOut = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(memOut, data, header);
byte[] toSend = memOut.ToArray();
int sent = Connection.Send(toSend);
while(sent != toSend.Length)
{
sent += Connection.Send(toSend, sent, toSend.Length - sent,
SocketFlags.None);
}
}
....
- but I've no idea how to make proper header value - that would work...
So, the question is:
How to make proper conversation with Java Object Streams from C# language...
....receiving objects is also needed...
My data objects from/to java server usually are strings, int, longs, bytes,
dates, arrays and multidimensional arrays of its...
Do you have any ideas or advices for me ?
Regards,
Chris
There is a Java (SUN 1.4) server which using Object Input/Output Streams at
SSL/Socket to communicate with Java clients.
Now there is a request for making C# Client for this server also.
SSL layer could be done with Org.Mentalis.Security.dll from seclib-1.0
Mentalis package - its fine...
But, threre is a problem:
How to properly communicate from C# language to Java.ObjectInputStream -
cause I've tried many times, and always get the Java exception about wrong
stream header.
I've tought about using such code:
....
Connection = new SecureSocket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp, options);
Connection.Connect(new IPEndPoint(Dns.Resolve(server).AddressList[0],
int.Parse(port)));
Send("GET_SERVER_VERSION.CSHARP.SSL.MENTALIS\r\n", "UNKNOWN HEADER");
....
protected void Send(string data, Header header) {
System.IO.MemoryStream memOut = new System.IO.MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(memOut, data, header);
byte[] toSend = memOut.ToArray();
int sent = Connection.Send(toSend);
while(sent != toSend.Length)
{
sent += Connection.Send(toSend, sent, toSend.Length - sent,
SocketFlags.None);
}
}
....
- but I've no idea how to make proper header value - that would work...
So, the question is:
How to make proper conversation with Java Object Streams from C# language...
....receiving objects is also needed...
My data objects from/to java server usually are strings, int, longs, bytes,
dates, arrays and multidimensional arrays of its...
Do you have any ideas or advices for me ?
Regards,
Chris