K
Khadim
I am using the following code, don't know what am i missing. in BYTE2 I
am not getting any information from the remote application.
any guidance would be highly appreciated, thanking you in advance
// PatentRequestPaket is a structure defined above in the class
//public struct PatentRequestPacket
//{
// public char[] Key;// = new char[15];
// public char[] PatentNumber;// = new char[20];
// public int NumPages;
//}
PatentRequestPacket packet = new PatentRequestPacket();
PatentRequestPacket ackPacket = new PatentRequestPacket();
int m_nPort = 50055;
Socket ConnectSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
TcpClient socketForServer;
try
{
socketForServer = new TcpClient("127.0.0.1", 50055);
}
catch
{
Console.WriteLine(
"Failed to connect to server at {0}:999", "localhost");
return;
}
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse("127.0.0.1"),
50055);
ConnectSocket.Connect(ipEnd);
NetworkStream networkStream = socketForServer.GetStream();
int bytesSent;
int m_nNumPages = -1;
packet.Key = m_strKey.ToCharArray();
packet.PatentNumber= "6655414".ToCharArray();
packet.NumPages = m_nNumPages;
byte[] BYTE = new byte[10000];
BYTE = RawSerialize(ackPacket);
byte[] BYTE2 = {Convert.ToByte('0')};
BYTE2= RawSerialize(packet);
ConnectSocket.Send(BYTE);
ConnectSocket.Receive(BYTE2);
// Rawserialize is a method defined in the class
// public static byte[] RawSerialize( object anything )
// {
// int rawsize = Marshal.SizeOf( anything );
// IntPtr buffer = Marshal.AllocHGlobal( rawsize );
// Marshal.StructureToPtr( anything, buffer, false );
// byte[] rawdatas = new byte[ rawsize ];
// Marshal.Copy( buffer, rawdatas, 0, rawsize );
// Marshal.FreeHGlobal( buffer );
// return rawdatas;
// }
am not getting any information from the remote application.
any guidance would be highly appreciated, thanking you in advance
// PatentRequestPaket is a structure defined above in the class
//public struct PatentRequestPacket
//{
// public char[] Key;// = new char[15];
// public char[] PatentNumber;// = new char[20];
// public int NumPages;
//}
PatentRequestPacket packet = new PatentRequestPacket();
PatentRequestPacket ackPacket = new PatentRequestPacket();
int m_nPort = 50055;
Socket ConnectSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
TcpClient socketForServer;
try
{
socketForServer = new TcpClient("127.0.0.1", 50055);
}
catch
{
Console.WriteLine(
"Failed to connect to server at {0}:999", "localhost");
return;
}
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse("127.0.0.1"),
50055);
ConnectSocket.Connect(ipEnd);
NetworkStream networkStream = socketForServer.GetStream();
int bytesSent;
int m_nNumPages = -1;
packet.Key = m_strKey.ToCharArray();
packet.PatentNumber= "6655414".ToCharArray();
packet.NumPages = m_nNumPages;
byte[] BYTE = new byte[10000];
BYTE = RawSerialize(ackPacket);
byte[] BYTE2 = {Convert.ToByte('0')};
BYTE2= RawSerialize(packet);
ConnectSocket.Send(BYTE);
ConnectSocket.Receive(BYTE2);
// Rawserialize is a method defined in the class
// public static byte[] RawSerialize( object anything )
// {
// int rawsize = Marshal.SizeOf( anything );
// IntPtr buffer = Marshal.AllocHGlobal( rawsize );
// Marshal.StructureToPtr( anything, buffer, false );
// byte[] rawdatas = new byte[ rawsize ];
// Marshal.Copy( buffer, rawdatas, 0, rawsize );
// Marshal.FreeHGlobal( buffer );
// return rawdatas;
// }