Subject: have a problem in frmFileTransfer.cs
I port frmFileTransfer.cs of sample MiniClient on PC into Mobile,
I use socks5 proxy, when i send a file from Mobile to PC, there is a error at SendFile(IAsyncResult ar) in the file frmFileTransfer.cs.
there is no Monitor in .net cf 2.0, so I instead Monitor2 of OpenNETCF in JEP65Socket.cs
try
{
_p2pSocks5Socket.Socket.EndReceive(ar);
//Error at it
}
//Debug information;
The thread 0x6ecfdd3a has exited with code 0 (0x0).
A first chance exception of type 'System.ArgumentException' occurred in System.dll
System.ArgumentException:
at System.Net.Sockets.Socket.EndReceive()
at imaw.FileTransferForm.SendFile()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
The thread 0xcdd178c2 has exited with code 0 (0x0).
A first chance exception of type 'System.ArgumentException' occurred in System.dll
System.ArgumentException:
at System.Net.Sockets.Socket.EndReceive()
at imaw.FileTransferForm.SendFile()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
create new thread where calling SendFile function every time, also throw exception.
but MiniClient client only produce a thread, when calling sendFile function, also no exception
I use socks5 proxy, when i send a file from Mobile to PC, there is a error at SendFile(IAsyncResult ar) in the file frmFileTransfer.cs.
there is no Monitor in .net cf 2.0, so I instead Monitor2 of OpenNETCF in JEP65Socket.cs
private void SendFile(IAsyncResult ar)
{
const int BUFFERSIZE = 1024;
byte[] buffer = new byte[BUFFERSIZE];
FileStream fs;
// AsyncResult is null when we call this function the 1st time
if (ar == null)
{
m_startDateTime = DateTime.Now;
fs = new FileStream(m_FileName, FileMode.Open);
}
else
{
if (_p2pSocks5Socket.Socket.Connected)
{
try
{
_p2pSocks5Socket.Socket.EndReceive(ar);
[color=crimson][b] //Error at it[/b][/color]
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
fs = ar.AsyncState as FileStream;
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
// to udate the progress bar
TimeSpan ts = DateTime.Now - m_lastProgressUpdate;
if (ts.Seconds >= 1)
{
BeginInvoke(new ObjectHandler(UpdateProgress), new object[] { this });
}
}
int len = fs.Read(buffer, 0, BUFFERSIZE);
m_bytesTransmitted += len;
if (len > 0)
{
_p2pSocks5Socket.Socket.BeginSend(buffer, 0, len, System.Net.Sockets.SocketFlags.None, SendFile, fs);
}
else
{
// Update Pogress when finished
BeginInvoke(new ObjectHandler(UpdateProgress), new object[] { this });
fs.Close();
//fs.Dispose();
if (_p2pSocks5Socket != null && _p2pSocks5Socket.Connected)
_p2pSocks5Socket.Disconnect();
}
}
{
const int BUFFERSIZE = 1024;
byte[] buffer = new byte[BUFFERSIZE];
FileStream fs;
// AsyncResult is null when we call this function the 1st time
if (ar == null)
{
m_startDateTime = DateTime.Now;
fs = new FileStream(m_FileName, FileMode.Open);
}
else
{
if (_p2pSocks5Socket.Socket.Connected)
{
try
{
_p2pSocks5Socket.Socket.EndReceive(ar);
[color=crimson][b] //Error at it[/b][/color]
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
fs = ar.AsyncState as FileStream;
// Windows Forms are not Thread Safe, we need to invoke this :(
// We're not in the UI thread, so we need to call BeginInvoke
// to udate the progress bar
TimeSpan ts = DateTime.Now - m_lastProgressUpdate;
if (ts.Seconds >= 1)
{
BeginInvoke(new ObjectHandler(UpdateProgress), new object[] { this });
}
}
int len = fs.Read(buffer, 0, BUFFERSIZE);
m_bytesTransmitted += len;
if (len > 0)
{
_p2pSocks5Socket.Socket.BeginSend(buffer, 0, len, System.Net.Sockets.SocketFlags.None, SendFile, fs);
}
else
{
// Update Pogress when finished
BeginInvoke(new ObjectHandler(UpdateProgress), new object[] { this });
fs.Close();
//fs.Dispose();
if (_p2pSocks5Socket != null && _p2pSocks5Socket.Connected)
_p2pSocks5Socket.Disconnect();
}
}
try
{
_p2pSocks5Socket.Socket.EndReceive(ar);
//Error at it
}
//Debug information;
The thread 0x6ecfdd3a has exited with code 0 (0x0).
A first chance exception of type 'System.ArgumentException' occurred in System.dll
System.ArgumentException:
at System.Net.Sockets.Socket.EndReceive()
at imaw.FileTransferForm.SendFile()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
The thread 0xcdd178c2 has exited with code 0 (0x0).
A first chance exception of type 'System.ArgumentException' occurred in System.dll
System.ArgumentException:
at System.Net.Sockets.Socket.EndReceive()
at imaw.FileTransferForm.SendFile()
at System.Net.LazyAsyncResult.InvokeCallback()
at WorkerThread.doWork()
at WorkerThread.doWorkI()
at WorkItem.doWork()
at System.Threading.Timer.ring()
create new thread where calling SendFile function every time, also throw exception.
but MiniClient client only produce a thread, when calling sendFile function, also no exception
jimsky
Show profile
Link to this post
