Solved

sending and receiving data from server to client and vice versa using indy9

Posted on 2006-10-29
5
201 Views
Last Modified: 2010-04-05
Hi all!

How can a server send data to client? Like if the server wants to logoff the clients station...
And also if the client wants to logoff, how can the client send data to the server.
All i need is the sending process or i mean how can i trigger the server station to client station and vice versa.
Im going to use Delphi 7 and Indy 9.

I dont know if you guys understand me. Sorry for my english.
By the way, Im making an internet cafe program.
Thanks
0
Comment
Question by:tirbanqs
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17832142
Take a look at the Indy website.

http://adg.bmpcoe.org/IndySSL/

They have some good starter examples for you to learn from  :o)
0
 

Author Comment

by:tirbanqs
ID: 17838535
Thanks. But i need a more detailed code with my problem. I havent found the exact server to client data sending like logging off the clients station.
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17839115
to send data to the client within the server's "OnExecute" code you can just go
AThread.Connection.WriteLn('Please go away now');
and the client could see that and disconnect
s := IdTCPCLient1.readLn;
if s = 'Please go away now' then IdTCPClient1.Disconnect;

of course, you could just have the server disconnect the client...
AThread.Connection.Disconnect;

If you need to send a message to a client, but you are not within the onececute event, you could iterate through all the clients and send the message that way
eg.

    with IdTCPServer1.Threads.LockList do
    try
        for i := 0 to Count - 1 do
        begin
              if (
                   (TIdPeerThread(Items[i]).Connection.Socket.Binding.PeerIP = '127.0.0.1')
{if you know the port you wish to talk to, you could also check
                   and (TIdPeerThread(Items[i]).Connection.Socket.Binding.PeerPort = 12345)
Normally I'd have an "id" or "name" property set in teh ".Data" pointer (as an object) so I'd just find it that way
                  ) then TIdPeerThread(Items[i]).Connection.Writeln('I''m talking to you');
             
     finally
        IdTCPServer1.Threads.UnLockList;
     end;

I do not recall the commands to "logoff" a user's machine, but I think it's something like
ExitWindowsEx(EWX_LOGOFF + EWX_FORCE, 0);

but if you still wanted to be able to commiunicate if the client logs their machine off, then make this a service (which will run even if no one is logged on to the machine)

0
 

Author Comment

by:tirbanqs
ID: 17840233
Thanks. Can you give me a working project for the server and client.
Im still having trouble. I implemented the code but still the client didnt receive the data sent
by the server. Sorry. Ill raise the points to 400. Thanks :)
Send it to my email: tirbanx@gmail.com
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 250 total points
ID: 17840353
I have a few demos here
http://sourceforge.net/projects/internetdemos/files
that might give you an idea on how the communication between client and server goes anyway.
I'm about to rewrite the demos, but they are still valid
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
Delphi selector screen 2 79
Create a path if not exists 7 77
IdTCPClient and IdTCPServer exchanging data on desktops and not Android 11 115
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question