get data from another computer

How can I retreive data (in my particular case, it's just the current date) in my program from another computer if they are both in the LAN?
LVL 21
YurichAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mblatCommented:
from command line

NET TIME \\rhea

where \\rhea is other computer name
0
YurichAuthor Commented:
Thanks for reply. I need to get this data in my program - nothing should be typed or pressed or clicked.
0
YurichAuthor Commented:
Thanks for reply. I need to get this data in my program - nothing should be typed or pressed or clicked.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

YurichAuthor Commented:
...well, probably i didn't put it clear enough. I don't need to display it, I need to get this date, assign it a variable (or class instance) and then do some operations on it (or using it)...
0
mblatCommented:
well, easiest ( and at the same time 'dirty' way ) of doing it would be to run

NET TIME \\OTHER_COMPUTER_NAME > otherComputerName.txt using WinExec or CreateProcess....

Then read the file....

Of cause there have to be an API call to do it, just slips my mind right now.

Other note:  You have to have permissions to access other computer and this is not trivial issue by itself...


I'll look around if i'll find an API call i'll post it here
0
YurichAuthor Commented:
...thanks again... all permissions are not a problem - that should work, a little mess with dos commands and reading files... what api call do you mean? to read a file or what? ...to make it a little bit more "civilized", i'd rather probably use two program, one on each computer, and make'em to communicate each other without using net prompt commands... yet in this case i need a programming running on the remote pc at the time i need access and probably it would involve more work to do...
0
YurichAuthor Commented:
...redirection ">" doesn't work... is there another way to place this data into the file?...
0
ice911Commented:
yeah that is what i'm doing right now, but i'm passing around network information from computers on a lan and only these computers that have my program running can recieve the data.

my program sends a request out to another computer running my program and then the other computer recieves the request for data and sends back what is necessary to send back in this data structure that the computer requesting can handle.

what your doing is very much like what i'm doing.

you could send a data structure or have the other computer write to a text file and send that.

-ice911

p.s. just adding some input
0
ice911Commented:
check out winsock.h

to send and recieve over networks
0
YurichAuthor Commented:
...redirection ">" doesn't work... is there another way to place this data into the file?...
0
CraigBallCommented:
Using CSocket:

Create a CSocket listening socket on the machine you want the data to go to (dest).
In the OnAccept() on the dest machine, redirect the connection to another CSocket to establish the network link.
Create a CSocket on the source machine.
Use CSocket::Connect() to connect to the dest
Send the time using the CSocket::Send()
Override the OnReceive() on the dest machine
In the OnReceive(), read in the time and set.

A bit pseudo-code, but it you need more detail, let me know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mblatCommented:
...redirection ">" doesn't work... is there another way to place this data into the file?...

It doesn;t work in what manner?  If command fails it doesn't, but it run ok then it should work just fine.
0
mblatCommented:
any way if running programs on both machines is an option ( i didn't think it was) then check this out:

http://codeguru.com/network/NDK2.html

there are some other smaples here

http://codeguru.com/network/index.shtml

And I meant API that produces same result as

NET TIME \\other_computer

command

There is got to be one - I just don't rememeber what it is now.  ( IT is somewaht out of my area).

Hope it helps.
0
keitha1Commented:
Check out the MailSlot API.
0
YurichAuthor Commented:
thanks to everybody for all suggestions... i'm going to use sockets to implement this program...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

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.