?
Solved

get data from another computer

Posted on 2003-03-17
15
Medium Priority
?
298 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:Yurich
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 8154627
from command line

NET TIME \\rhea

where \\rhea is other computer name
0
 
LVL 21

Author Comment

by:Yurich
ID: 8155365
Thanks for reply. I need to get this data in my program - nothing should be typed or pressed or clicked.
0
 
LVL 21

Author Comment

by:Yurich
ID: 8155547
Thanks for reply. I need to get this data in my program - nothing should be typed or pressed or clicked.
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 21

Author Comment

by:Yurich
ID: 8155616
...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
 
LVL 4

Expert Comment

by:mblat
ID: 8155670
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
 
LVL 21

Author Comment

by:Yurich
ID: 8155782
...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
 
LVL 21

Author Comment

by:Yurich
ID: 8156302
...redirection ">" doesn't work... is there another way to place this data into the file?...
0
 
LVL 1

Expert Comment

by:ice911
ID: 8156328
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
 
LVL 1

Expert Comment

by:ice911
ID: 8156336
check out winsock.h

to send and recieve over networks
0
 
LVL 21

Author Comment

by:Yurich
ID: 8156464
...redirection ">" doesn't work... is there another way to place this data into the file?...
0
 

Accepted Solution

by:
CraigBall earned 200 total points
ID: 8157788
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
 
LVL 4

Expert Comment

by:mblat
ID: 8160893
...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
 
LVL 4

Expert Comment

by:mblat
ID: 8160918
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
 
LVL 1

Expert Comment

by:keitha1
ID: 8161359
Check out the MailSlot API.
0
 
LVL 21

Author Comment

by:Yurich
ID: 8177109
thanks to everybody for all suggestions... i'm going to use sockets to implement this program...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

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