Hello, i've a server and client code in which the error i'm getting is: on deserialization-
but when i checked the byte[] length after serialization that i send they are 1550, and then over the tcpclient when i received the byte[] it was 1448 in length...
any help or suggestion would be appreciated
**CLIENT CODE**
static void Main()
{
Application.Run(new Form2connectclient2library());
}
public void cmdConnect_Click(object sender, System.EventArgs e)
{
try
{
//****************************TCP NETWORK STREAM*******
port = Convert.ToInt32(txtPort.Text);
ip = txtIPAddress.Text;
myclient = new TcpClient(ip, port);
recByte = new byte[myclient.ReceiveBufferSize];
AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
(myclient.GetStream()).BeginRead(recByte, 0, myclient.ReceiveBufferSize, GetMsgCallback, null);
//*****************************************************
}
catch (SocketException se)
{
MessageBox.Show(se.Message);
}
}
NetworkStream n;
public void GetMsg(IAsyncResult ar)
{
int byteCount;
try
{
lock (myclient.GetStream())
{
n = (NetworkStream)ar.AsyncState;
//Get the number of Bytes received
byteCount = (myclient.GetStream()).EndRead(ar);
}
if (byteCount > 1)
{
MessageBox.Show(byteCount.ToString());
M7_1.MessageWrapper_Download msg = (M7_1.MessageWrapper_Download)M7_1.class_ser_deser.DeSerializer(recByte, recByte.Length);
if (msg.getType() == M7_1.MessageWrapper_Download.MESSAGETYPE.GET_GROUPS)
{
DataSet ds_g = (DataSet)msg.msgdata();
obj.set_groups_list(ds_g);
}
if (msg.getType() == M7_1.MessageWrapper_Download.MESSAGETYPE.GET_DOCUMENTS)
{
DataSet ds_r = (DataSet)msg.msgdata();
obj.set_Resource_List(ds_r);
}
if (msg.getType() == M7_1.MessageWrapper_Download.MESSAGETYPE.FILE)
{
D_dataTransferObjs obj_file = (D_dataTransferObjs)msg.msgdata();
obj.createFile(obj_file);
}
}
obj.send_client_obj(myclient);
recByte = new byte[myclient.ReceiveBufferSize];//Start a new asynchronous read into readBuffer.
AsyncCallback GetMsgCallback = new AsyncCallback(GetMsg);
(myclient.GetStream()).BeginRead(recByte, 0, myclient.ReceiveBufferSize, GetMsgCallback, this);
}
catch (Exception ed)
{
myclient.Close();
MessageBox.Show("Client Disconnected ");
MessageBox.Show(ed.ToString());
}
}