Recent

Author Topic: What controls open network connections, Windows and Linux.  (Read 6943 times)

marsheng

  • Jr. Member
  • **
  • Posts: 53
What controls open network connections, Windows and Linux.
« on: March 29, 2022, 10:17:27 pm »
A work around in windows is to map a network drive to a drive letter and then it can be found with SheelTreeView or open dialog. 

I haven't found anything similar with Linux.

Does lazarus have an Network viewer control for either OS ? 

It looks like the OS handle them quite differently.

Warfley

  • Hero Member
  • *****
  • Posts: 2067
Re: What controls open network connections, Windows and Linux.
« Reply #1 on: March 30, 2022, 10:36:56 am »
What do you mean by open network connections. What windows shows you here are devices that provide access through some protocols windows knows (like SMB). These aren't like open connections, these are just devices in the network with certain ports open.
If you want to get this on linux check out NMap

MarkMLl

  • Hero Member
  • *****
  • Posts: 8572
Re: What controls open network connections, Windows and Linux.
« Reply #2 on: March 30, 2022, 10:40:04 am »
What do you mean by open network connections. What windows shows you here are devices that provide access through some protocols windows knows (like SMB). These aren't like open connections, these are just devices in the network with certain ports open.
If you want to get this on linux check out NMap

I see what he's getting at, but the truth of the matter is that desktop environments go to a great deal of trouble to accommodate multiple protocols- e.g. SMB, NFS and FISH- and I suspect there's no simple answer.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PierceNg

  • Sr. Member
  • ****
  • Posts: 435
    • SamadhiWeb
Re: What controls open network connections, Windows and Linux.
« Reply #3 on: March 30, 2022, 11:39:03 am »
A work around in windows is to map a network drive to a drive letter and then it can be found with SheelTreeView or open dialog. 

I haven't found anything similar with Linux.

Linux has no drive letters. Filesystems (what we think of as drive E, drive F, etc in Windows) are mapped under the root directory "/". By convention temporary mounts done manually are mounted at /mnt. On desktop Ubuntu, automated mounts, such as when I plug in a USB drive, go under /media/<my username>/<UUID of drive>; other desktop Linux may have other conventions.

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #4 on: March 30, 2022, 11:48:27 am »
I wonder if the OP is referring to the way things on Linux get mapped via, for example, gvfs ?  I have a SMB share that shows up beautifully in my Caja file browser but looks like this if I want to find it in an application (such as in a LCL FileOpenDialog) -

Code: Bash  [Select][+][-]
  1. /run/user/1000/gvfs/smb-share\:server\=greybox\,share\=store2/

And thats quite messy and quite difficult to tell an end user where to go searching ....

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 8572
Re: What controls open network connections, Windows and Linux.
« Reply #5 on: March 30, 2022, 12:04:32 pm »
By convention temporary mounts done manually are mounted at /mnt. On desktop Ubuntu, automated mounts, such as when I plug in a USB drive, go under /media/<my username>/<UUID of drive>; other desktop Linux may have other conventions.

It varies. I'm reasonably confident that temporary mounts under /media will work for most Debian derivatives, but I've seen systems which mount stuff under rather than at /mnt and getting that wrong would cause major grief.

I think the bottom line is that OP is used to a graphical presentation, and that the various desktop environments- irrespective of base OS- present e.g. a newly-hotplugged USB drive as an item in a pane rather than as a node in a tree.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Warfley

  • Hero Member
  • *****
  • Posts: 2067
Re: What controls open network connections, Windows and Linux.
« Reply #6 on: March 30, 2022, 01:33:19 pm »
And then you get to users like me, who simply mount everything into their home directory :D

For finding mount points on linux the best option is to use the mount or df utility, or by reading the /proc pseudofiles mounts and mountsinfo.
More information can be found here: https://linoxide.com/list-mounted-drives-on-linux/

The problem is that under linux mounting directories into the file system is very common, not just network mounts, so this list needs to be filtered.

But that said, in the original post, the thread creator showed (in the screen shot) the network section of windows shell tree view. These are not mounted drives, but are the results of windows actively searching servers in the local network that *could* be connected to, but not necessarily are mounted (e.g. this shows other PCs in the network, even though you require their login data to access their shared files).
So this is something that linux simply does not do. This is why I origninally talked about using NMap for this

MarkMLl

  • Hero Member
  • *****
  • Posts: 8572
Re: What controls open network connections, Windows and Linux.
« Reply #7 on: March 30, 2022, 01:40:32 pm »
For finding mount points on linux the best option is to use the mount or df utility, or by reading the /proc pseudofiles mounts and mountsinfo.
More information can be found here: https://linoxide.com/list-mounted-drives-on-linux/

The problem is that under linux mounting directories into the file system is very common, not just network mounts, so this list needs to be filtered.

And that's increasingly true with more and more temporary filesystems set up by systemd et al.

Another extremely useful utility is lsblk.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #8 on: March 31, 2022, 01:08:04 am »
No guys, I think you are missing the question.

The OP wants a control to view potential or real mounts, in the same way that Linux File Managers allow you to browse "network drives", choose the one you want to look at graphically.  I imagine that he/she would like to see network shares in, for example, a TOpenDialog. (Hmm, so would I)

As noted above, the File Managers's GVFS helpers use obscure mount points under /media or /run and while its possible to browse to them using eg TOpenDialog its not obvious.

This was not always the case, some years ago, before Desktops standardised on GVFS, you could often see a share in the LCL's file/directory dialogs.

I wonder if we could call GVFS from LCL to get that information cleanly ?

As far as using mount, lsblk etc, come on, we are looking for a GUI solution that shows shares of interest to the user. Not snaps (turns, spits on ground), cgroups etc.

So yes, I agree with the user, a 'control' that shows shares is needed. Maybe a option to TOpenDialog and its friends ?

Davo

Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #9 on: March 31, 2022, 03:23:21 am »
OK, I lie !

I just tested what I was going on about above and it works fine on three out of three (linux) systems.

So, as long as you have an existing connection, ie a SMB or usb key plugged in, they show up fine in the TOpenDialogs. This is clearly something that has been fixed in the last year or so. Its a while since I tested it (and grizzled about it). I can now remove a whole lot of needlessly complicated user instructions !

But what is missing is the ability to initial make that (eg) SMB connection and that may well be the control the OP is wishing for. A GVFS thing ....

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

PascalDragon

  • Hero Member
  • *****
  • Posts: 6398
  • Compiler Developer
Re: What controls open network connections, Windows and Linux.
« Reply #10 on: March 31, 2022, 09:26:23 am »
This was not always the case, some years ago, before Desktops standardised on GVFS, you could often see a share in the LCL's file/directory dialogs.

I would hardly call GVFS standard, when it isn't used by e.g. KDE which uses KIO instead.

marsheng

  • Jr. Member
  • **
  • Posts: 53
Re: What controls open network connections, Windows and Linux.
« Reply #11 on: April 01, 2022, 12:19:07 am »
Thanks for the replies. Makes good reading.

>> The OP wants a control to view potential or real mounts, in the same way that Linux File Managers allow you to browse "network drives"  **************  Exactly

Maybe there is another way to skin a cat.

The problem.

I have a windows server and several machines around the workshop dumping files to CNC machines. On each CNC machine I have a PC which gets the files from the server. They all run Delphi programs at the moment. On each PC, I map the server drive and then Delphi can find the drive and files I need. 

I'm trying to change the PC next to the  CNC to  Linux boxes (PI) and change to Lazarus.

So the problem is, how do I find the files on the server using Lazarus controls. 

SheelTreeView from what I can see, cannot access my server files.  It only works locally. Is there another way or control to use?

It would be great if I could 'map' ShellTreeView to a server directory or remote drive.

PS My understanding of Linux core os is limited.


dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What controls open network connections, Windows and Linux.
« Reply #12 on: April 01, 2022, 01:22:41 am »
marsheng , there are two sides to this (important you see the difference) -

1. Making the connection between the local compter and the file server, in Unix speak, 'mounting'.

2. Showing files on that connected file server in a GUI component.

The first one, as far as I know is not handled by any component in in LCL. You could code it up easily enough using FPC's ability to execute command lines.

The second one ?  Well, as I demonstrated to my embarrassment above, LCL components such as TOpenDialog do show shares that have been mounted. I have not used ShellTreeView. Have you tried using ShellTreeView after you have mounted a share ?  If it does not work, then I guess it could be treated as a bug but its probably a case of no one has added the necessary code yet. I am sure it could be done. 

I'd be looking in the code of TOpenDialog to see how it extends its reach to those shares if I was you.

Alternatively, easier, you could use, directly, TOpenDialog and then FindFirst/FindNext and put the results into a eg TListVist, effectively making your own ShellTreeView. Thats how I work.

Getting back to Point One, how you would programmatically mount a share will depend on what sort of share it is, SMB, NFS, USB drive etc ?  I'd guess SMB, so you will end up calling a command line involving the smbclient program. If you can assume pre knowledge of what the server and the share are called, thats pretty easy. If you need to need to search for a likely network share, somewhat harder.

If you can instruct the end user to mount the share before using your app, its a "no issue".

Davo

EDIT: OK, just had a brief play with TShellTreeView and TShellListView. As you indicated, TShellTreeView does not show you mounted shares as "shares", but you can browse to eg /run/user/1000/gvfs/mysambashare and so view the files in it in the TShellListView.  I suggest if you require your users to do that, they will hate you !
« Last Edit: April 01, 2022, 01:54:12 am by dbannon »
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

marsheng

  • Jr. Member
  • **
  • Posts: 53
Re: What controls open network connections, Windows and Linux.
« Reply #13 on: April 01, 2022, 03:50:43 am »
Thanks dbannon, I think I have enough to go forward on now.

I am saving the last used directory to an INI when I open a file so at least  /run/user/1000/gvfs/mysambashare or what ever will be reloaded next time I run the program and will be in the right place.

I've just googled map vers mount and see the difference.  After all my windows complaints, I'll give it a +1 for mapping.

From the outside, Linux looks excellent,  everything just works, wireless, speakers etc, but, once inside the number of files and directories etc it seems a mess. Not even sure how to sort files and directories into alphabetical order. I'll leave that for another day.

marsheng

  • Jr. Member
  • **
  • Posts: 53
Re: What controls open network connections, Windows and Linux.
« Reply #14 on: April 02, 2022, 04:19:18 pm »
I've attached 2 screen shots using OpenDialog. Windows shows network drives but Linux not.

I'm running the standard LinuxMint 20. So how do I access network files from within Lazarus ?

 

TinyPortal © 2005-2018