G
Guest
Hi..
i having develop with vs.net2.0 and ce4.2.
but, occur critical problem..
debugging mode success, but deploy mode is fail..
have occur delay in socket communication?
help me... please!!!
<client..PDA>
public bool SendImage(Socket socket, byte[] imageContent)
{
try
{
int size = imageContent.Length;
int totalSent = 0, sent;
int leftData = size;
while (totalSent < size)
{
sent = socket.Send(imageContent, totalSent, leftData,
SocketFlags.None);
totalSent += sent;
leftData -= sent;
Thread.Sleep(700); <-- if no sleep in release mode,
fail server side, but debugging mode is success
}
return true;
}
catch (Exception)
{
return false;
}
}
<server-window app>
public Image ReceiveImage(Socket socket, long imageSize)
{
int recv;
int totaldata = 0;
int leftdata = (int)imageSize;
byte[] buffer = new byte[(int)imageSize];
while (totaldata < imageSize)
{
recv = socket.Receive(buffer, totaldata, leftdata,
SocketFlags.None);
if (recv == 0)
{
buffer = Encoding.ASCII.GetBytes("exit");
break;
}
totaldata += recv;
leftdata -= recv;
}
MemoryStream ms = new MemoryStream(buffer, true);
ms.Write(buffer, 0, buffer.Length);
Image image = Image.FromStream(ms);
ms.Flush();
ms.Close();
return image;
}
i having develop with vs.net2.0 and ce4.2.
but, occur critical problem..
debugging mode success, but deploy mode is fail..
have occur delay in socket communication?
help me... please!!!
<client..PDA>
public bool SendImage(Socket socket, byte[] imageContent)
{
try
{
int size = imageContent.Length;
int totalSent = 0, sent;
int leftData = size;
while (totalSent < size)
{
sent = socket.Send(imageContent, totalSent, leftData,
SocketFlags.None);
totalSent += sent;
leftData -= sent;
Thread.Sleep(700); <-- if no sleep in release mode,
fail server side, but debugging mode is success
}
return true;
}
catch (Exception)
{
return false;
}
}
<server-window app>
public Image ReceiveImage(Socket socket, long imageSize)
{
int recv;
int totaldata = 0;
int leftdata = (int)imageSize;
byte[] buffer = new byte[(int)imageSize];
while (totaldata < imageSize)
{
recv = socket.Receive(buffer, totaldata, leftdata,
SocketFlags.None);
if (recv == 0)
{
buffer = Encoding.ASCII.GetBytes("exit");
break;
}
totaldata += recv;
leftdata -= recv;
}
MemoryStream ms = new MemoryStream(buffer, true);
ms.Write(buffer, 0, buffer.Length);
Image image = Image.FromStream(ms);
ms.Flush();
ms.Close();
return image;
}