Android Question Network Login to Windows PC Shared Folder

A Z M JANNAT UL KARIM

Member
Licensed User
Hi, I am using an apps in local computer which will access some images from network URL like \\192.168.0.22\image$\image01.jpg and put in some label. But the shared folder can only be access through some login credential. Can I use any Login credential from Apps before accessing the file. Thank you :)
 

A Z M JANNAT UL KARIM

Member
Licensed User
Hi Markus, thank you for your link. I had tried it now and for some reason I am getting following error !!!

B4X:
Logger connected to:  HUAWEI BGO-DL09
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (smb1_listcompleted)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (smb1_listcompleted)
running waiting messages (1)
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ListCompleted
ListFiles failed : (SmbException) jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.2.246
jcifs.util.transport.TransportException
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
    at jcifs.util.transport.Transport.readn(Transport.java:29)
    at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288)
    at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319)
    at jcifs.util.transport.Transport.run(Transport.java:241)
    at java.lang.Thread.run(Thread.java:833)
Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:189)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
    ... 9 more
    at jcifs.util.transport.Transport.run(Transport.java:258)
    at java.lang.Thread.run(Thread.java:833)

For Information the folder is in Windows 10 v1903 System. Had turn off password protected sharing. Folder shared with Everyone / Read Only. Also had SetCredentials for it. Following is the code for your reference ...

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    If FirstTime Then
        SMB1.SetCredentials("user","123456","")
        SMB1.Initialize("SMB1")
    End If
    SMB1.ListFiles("smb://192.168.2.246/images/", "")
End Sub

Sub SMB1_ListCompleted(Url As String, Success As Boolean, Entries() As SMBFile)
Log("ListCompleted")
' Return
  If Not(Success) Then
      Log("ListFiles failed : " & LastException)
  Else
    For i = 0 To Entries.Length - 1
        Log("*****************")
        Log(Entries(i).Name)
        Log(Entries(i).Directory)
        Log(DateTime.Date(Entries(i).LastModified))
        Log(Entries(i).Parent)
        Log(Entries(i).Size)
      Next
  End If
End Sub

Thank you ...
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
you checked also windows firewall?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top