Results 1 to 3 of 3

Thread: How find/refresh SAMBA shares on a local network with c/c++

Hybrid View

  1. #1

    Default How find/refresh SAMBA shares on a local network with c/c++

    I am writing a c++ program on a Leap 15.1 (KDE) computer that accesses files on a SAMBA share in a local network. However, I’m finding that if the ip address lease expires the connection to the SAMBA share is lost.


    If I type “smb://sharename” into the address bar of Dolphin, it causes the system to renew the ip address and my connection can be resumed.

    My question is – what c or c++ functions can I call to provide the same outcome as Dolphin?



    Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,383
    Blog Entries
    1

    Default Re: How find/refresh SAMBA shares on a local network with c/c++

    Quote Originally Posted by 42LeapsOfFaith View Post
    I am writing a c++ program on a Leap 15.1 (KDE) computer that accesses files on a SAMBA share in a local network. However, I’m finding that if the ip address lease expires the connection to the SAMBA share is lost.


    If I type “smb://sharename” into the address bar of Dolphin, it causes the system to renew the ip address and my connection can be resumed.

    My question is – what c or c++ functions can I call to provide the same outcome as Dolphin?



    Thanks in advance.
    I'm not a programmer, but the gethostbyname function can be used to resolve hostnames using the name resolution protocols defined in /etc/nsswitch.conf....
    https://www.binarytides.com/hostname...sockets-linux/
    https://www.geeksforgeeks.org/c-prog...me-ip-address/
    https://stackoverflow.com/questions/...-in-background
    Last edited by deano_ferrari; 17-Aug-2019 at 02:03.
    openSUSE Leap 15.0; KDE Plasma 5

  3. #3

    Default Re: How find/refresh SAMBA shares on a local network with c/c++

    Thank you @deano_ferrari for your reply.

    gethostbyname() is where I started, but it doesn't work in this scenario.

    The code is to run on a Leap15.1 workstation, the server (also Linux) managers the DNS, the SAMBA share is on a NAS (on the same local network). There are also various Windows workstations on this local network - they work okay in this scenario.

    The problem seems to be that the server doesn't automatically renew the ip address of the NAS when the lease expires. I don't have access to the server to alter its behaviour.

    The Windows workstations (through drive mapping) somehow trigger the server to renew the NAS ip address lease, as does Dolphin on the Leap15.1...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •