'code wont continue after a certain method is called
I have a few lines
Encryption enc = new Encryption();
enc.SendAsymetricencrypt(client.GetStream(), rsa);
it goes in to SendAsymetricencrypt just fine, problem is that it never comes out
public void SendAsymetricencrypt(NetworkStream clientsStream, RSA rsa)
{
//at the start of client he creates an asymetric key and
//sending it to the server so the server could send back
//safely the symetric key
RSAParameters publickeyInfo = rsa.ExportParameters(false);
//<summry>
//sends the Modulus
//</summry>
//just the length of mod
string ModLen = publickeyInfo.Modulus.Length.ToString();
//make md to array
byte[] addMD = Encoding.ASCII.GetBytes("@@@MD");
//prepare a new array with the requierd length
byte[] byteDataMod = new byte[int.Parse(ModLen) + addMD.Length];
//add addOn to array
addMD.CopyTo(byteDataMod, 0);
// add the mod to array
publickeyInfo.Modulus.CopyTo(byteDataMod, addMD.Length);
//send
clientsStream.Write(byteDataMod, 0, byteDataMod.Length);
clientsStream.Flush();
//<summry>
//sends the exponent
//</summry>
//just the length of ex
string ExLen = publickeyInfo.Exponent.Length.ToString();
//make ex to array
byte[] addEX = Encoding.ASCII.GetBytes("@@@EX");
//prepare a new array with the requierd length
byte[] byteDataEx = new byte[int.Parse(ExLen) + addEX.Length];
//add addOn to array
addEX.CopyTo(byteDataEx, 0);
// add the mod to array
publickeyInfo.Exponent.CopyTo(byteDataEx, addEX.Length);
//send
clientsStream.Write(byteDataEx, 0, byteDataEx.Length);
clientsStream.Flush();
}
debuging shows the program gets to the last line executes it and then just doesn't come back out to complete the rest of the code.
past the call I have
enc.SendAsymetricencrypt(client.GetStream(), rsa);
try
{
client.GetStream().BeginRead(data,
0,
System.Convert.ToInt32(client.ReceiveBufferSize),
ReceiveMessage,
null);
}
catch(Exception ex)
{
MessageBox.Show(Convert.ToString(ex));
}
I have a breakpoint at the try but it never even gets there.
what an u doing wrong?
I already checked and the bytes do get to the server just fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
