简体   繁体   中英

Сonnecting a phone via smb to a laptop

My laptop and phone are connected to wi-fi. There is a network folder on the laptop. To connect, I use the following code:

String URL = "smb://" + SERVER_ADDRESS + "/" + SHARED_FOLDER_NAME + "/" + FILE_NAME;
authentication = getPasswordAuthentication(null, null);
SmbFile dataFile = new SmbFile(URL, authentication);

private NtlmPasswordAuthentication getPasswordAuthentication(String user, String login)
{
    return (user != null && login != null)
            ? new NtlmPasswordAuthentication(user + ":" + login)
            : new NtlmPasswordAuthentication(null, null, null);
}

SERVER_ADDRESS is the ip address. My PC is 192.168.1.57, laptop is 192.168.1.36.

This code works correctly with my pc, but for some reason it doesn't on the laptop:

jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.1.36
W/System.err: jcifs.util.transport.TransportException
W/System.err: java.net.SocketException: Connection reset

I know for sure that the local folder on the laptop is configured correctly, since the standard file manager on my phone connects perfectly to the laptop and sees the folders I need.

The problem turned out to be that I forgot that I turned on SMB1 support on my PC.

Control panel -> Programs-> Programs and components -> Enable or disable components -> SMB 1.0 / CIFS File Sharing Support

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM