Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
jimsky #1
Member since Sep 2010 · 3 posts
Group memberships: Members
Show profile · Link to this post
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

      
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();
            }
        }

 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
Avatar
Alex #2
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Monitor is used to establish a connection to one of the offered streamhosts in a loop synchronous. You could replace this with synchronous socket functions.
I suggest to use our MatriX Mobile SDK which has a FileTransferManager in the latest binary release.
Avatar
jimsky #3
Member since Sep 2010 · 3 posts
Group memberships: Members
Show profile · Link to this post
3x.

the problem is not Monitor, because the exception at BeginReceive.

If I develop a free product,  do I need to purchase a license for using Matrix lib?
Besides,  does Matrix lib support .NET CF 2.0?

Quote by Alex:
The Monitor is used to establish a connection to one of the offered streamhosts in a loop synchronous. You could replace this with synchronous socket functions.
I suggest to use our MatriX Mobile SDK which has a FileTransferManager in the latest binary release.
Avatar
jimsky #4
Member since Sep 2010 · 3 posts
Group memberships: Members
Show profile · Link to this post
It has no FileTransferManager class in Matrix.dll of Mobile
Avatar
Alex #5
Member since Feb 2003 · 4307 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The latest binary has. You get it from here:
http://www.ag-software.net/downloads.html

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS