Giter Site home page Giter Site logo

Comments (9)

ume05rw avatar ume05rw commented on July 20, 2024

Thank you for using this!

I do not know what kind of scene it will happen, so imagine and write.
If you use it occasionally, library can not detect changes in the IP address of the device, use old IP address.

Once connected, Sharpcifs keeps holding the value of the local IP address at the time of connection.
If the address changes, try the SmbFile.Initialize();

Execution order is:
SharpCifs.Config.SetProperty ("jcifs.smb.client.laddr", [ip address]);
SmbFile.Initialize();
var smbFile = new SmbFile ("connection uri string");
var list = smbFile.listFiles();

I hope that Google Translate will show you well!

from sharpcifs.std.

glent1 avatar glent1 commented on July 20, 2024

The problem is caused by the call to Socket.SendToAsync(args) in the Send method of SocketEx. The Completed event in SocketAsyncEventArgs never gets called, because (I am guessing) it is running synchronously as mentioned here ...

https://blogs.msdn.microsoft.com/dotnet/2017/06/07/performance-improvements-in-net-core/

I read the source of socket.cs and whilst I think the boolean that SendToAsync sets might mean it ran synchronously, I'm not sure. If it is, just doing this in SocketEx.Send will fix the issue ...

if (SendToAsync(args))
{
if (!evt.Wait(_soTimeOut))
{
throw new TimeoutException("No data sent.");
}
}

If not, replacing the whole method with this ...

public void Send(byte[] buffer, int offset, int length, EndPoint destination = null)
{
using (var evt = new ManualResetEventSlim(false))
{

            base.BeginSendTo(buffer, offset, length, SocketFlags.None, destination ?? RemoteEndPoint, new AsyncCallback(delegate { evt.Set(); }), this);
            if (!evt.Wait(_soTimeOut))
            {
                throw new TimeoutException("No data sent.");
            }
        }
    }

definitely will.

from sharpcifs.std.

MCord avatar MCord commented on July 20, 2024

I am seeing the same behavior. You solution works perfectly. Thanks !

from sharpcifs.std.

ume05rw avatar ume05rw commented on July 20, 2024

Thanks for your feedbacks!

I could not reproduce in my own environment(Win10, .NetCore2.0 SDK),
"SocketAsyncEventArgs.Completed" event always raised on my code.
Please tell me about your environment.

and, fix SocketEx.cs on dev-branch:
https://github.com/ume05rw/SharpCifs.Std/blob/dev/SharpCifs.STD1.3/Util/Sharpen/SocketEx.cs

I am glad if you try this code to see if it works correctly.

from sharpcifs.std.

glent1 avatar glent1 commented on July 20, 2024

Your environment is the same as mine. I am seeing the behaviour via a Windows .Net Core 2.0 Test Project. Interestingly, the problem does not happen in an Android deployment of the code.

Your dev-branch SocketEx fixes the problem.

I'm looking forward to you updating your nuget package so I can dispense with the local copy of the code.

By the way - thanks for this project!

from sharpcifs.std.

ume05rw avatar ume05rw commented on July 20, 2024

I published now, new ver 0.2.10.
https://www.nuget.org/packages/SharpCifs.Std/0.2.10

thank you everyone!

from sharpcifs.std.

ume05rw avatar ume05rw commented on July 20, 2024

Does anyone still have a look at this issue?
I could not reproduce this problem, so it's a bit indigestion...

If problems also occur, I will resume this issue!

from sharpcifs.std.

MCord avatar MCord commented on July 20, 2024

from sharpcifs.std.

MCord avatar MCord commented on July 20, 2024

from sharpcifs.std.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.