Application run over network causing problems....

Hi.

I have a client/server setup going on with a few applications.  The first application, the client, sends a message to the server application which does loads of stuff on another PC (not really relevant what it does), and then creates an output file.  Then, the viewer program is run on the client machine so that they can see the output.

The problem I have is that the "resources" are apparently still connected to the "client" machine.  (I should have mentioned that the client side software is all stored in a public directory on a seperate networked PC.)

For example, if I try to delete the viewer application, it won't let me, as if the program is still running.  But, if I view the "open resources" in the "control panel/server" applet, it shows the physical connections are still there.

I don't want every user to remain connected after they have used the software.

This is quite a serious issue and I need some help getting round it.  I'm not sure if the Delphi area is the best place to ask, but I'd prefer to solve the problem programatically, from within the software.

Thanks for any help,

John.
LVL 6
JaymolAsked:
Who is Participating?
 
geobulConnect With a Mentor Commented:
Hi John,

procedure TForm1.Button1Click(Sender: TObject);
var TheDll : dword;
    NetSessionDel : function (server, client, user: pWideChar) : dword; stdcall;
    res : dword;
    sWide : PWideChar;
    sWideLen : integer;
begin
  TheDll := LoadLibrary('netapi32.dll');
  NetSessionDel := GetProcAddress(TheDll, 'NetSessionDel');
  sWide := StringToWideChar(Edit1.Text,sWide,sWideLen);
  res := NetSessionDel(nil,nil,sWide);
  FreeLibrary(TheDll);
end;

// tested on NT4 server. Receives the user name from an edit box and closes his all connections.

Regards, Geo
0
 
EpsylonCommented:
Maybe you can make a local copy of the viewer application before running...
0
 
FrodoBegginsCommented:
This sounds like a server problem. You say that the viewer application is closed, but the .exe file remains open, right?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
JaymolAuthor Commented:
It's the physical connection to the machine which holds the client & viewing software that's the problem.

This remains, even though the app(s) are closed.

John.
0
 
FrodoBegginsCommented:
btw, I red somewhere in the MSDN (oh, somewhere in the MSDN!) that Microsoft recomends Excel to be started localy, because there is a problem if it is started from a server. The program itself looses the connection with the .exe file in the remote machine or something like that. Haveing local copy of the viewer is realy a good idea.
0
 
JaymolAuthor Commented:
Btw, I have checked the process list (NT4) and the apps are definately closed.

John.
0
 
JaymolAuthor Commented:
I'll try copying it locally 1st.

Ta.
0
 
geobulCommented:
Hi,
I'm afraid that it is a global NT problem. After some time of inactivity (undefined period - I have seen it for days), the NT will refresh its resources usage and will free them and disconnect the users. Moving the program to the client PC will not help you (the resources on the server will remain in use). The only way to do this from the remote PC, I've reached, is to disconnect the shared drive and connect it again.

Regards, Geo
0
 
JaymolAuthor Commented:
Thanks Geo, but if there's a button in the server applet that allows you to disconnect users, then there must be a way to do it programatically, therefore allowing me to disconnect a user, via the server application, once it knows the user is done.

Thanks,

John.
0
 
geobulCommented:
If you copy the program and the files it uses locally, it will solve the problem. Do not open them remotely using a local program.

Regards, Geo
0
 
JaymolAuthor Commented:
The files have to be available remotely as there are so many/they're so big.

John.
0
 
geobulCommented:
How could you know that the user has finished while the connection is still active? Such a program should be running on the server (as a service for example) and to disconnect users after a predefined idle period has been reached. But I have no code for doing this.

Regards, Geo
0
 
JaymolAuthor Commented:
The server application runs a process and then tells the client that it's done.  Therefore, the server knows it can close the connection before the client.

All I need now is to know how to close the connection.

John.
0
 
geobulCommented:
Take a look at NetSessionEnum and NetSessionDel API functions.

Regards, Geo
0
 
JaymolAuthor Commented:
I will.

Ta,

John.
0
 
geobulCommented:
Hi John,

Have you tested my last code? I forgot to say that the user name should not include the domain name and a slash.

Regards, Geo
0
 
JaymolAuthor Commented:
Sorry Geo, I haven't had chance yet.

I'll give it a go today and get back to you.

John.
0
 
geobulCommented:
Don't bother yourself. I have nowhere to hurry on. I was afraid that you hadn't seen it.

Regards, Geo
0
 
JaymolAuthor Commented:
Ok.  Ta.

John.
0
 
JaymolAuthor Commented:
Thanks for your help.

John.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.