tcp/ip connection

Hi,

under D3/WIN98 : two PC's are coupled via TCP/IP under WIN98.
when both pc's are started, all is ok: pc2 finds some special files
on the other pc.
now the problem: when pc1 is shut down, then pc2 does
not notice this. Only when he tries to find the special files. but this is too late.
Now the question: is it possible to test from pc2 wether pc1 is still
available or not ? Can you give me an example for the test, please ?

Thanks

Titz
LVL 1
titzAsked:
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.

edeyCommented:
you could ping the other computer


GL
Mike
0
craig_capelCommented:
edy, simple yet effective :)

Does Delphi 3 have built in TCP IP like D4?


Craig C.
0
craig_capelCommented:
oops, i mean edey AKA Mike
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

edeyCommented:
some versions of d3 do, mine (standard) does not :(.  Anyway, FPiettes comp's are really good :).

Gl
Mike
0
titzAuthor Commented:
how can a ping ?

cheers
titz
0
titzAuthor Commented:
or do you mean the "ping.exe" ?
Thios is a DOS-program, which i can not use. i am looking for a 32-bit-solution. i have delphi3 prof., i think there is a little bit more about tcp/ip than in d3 standard.

cheers
titz
0
XANCommented:
If I correct understand you use asynchronous connection. then you should correct process onDisconect event.

There are other way - you can use WinAPI function to work with sockets. In fact enough to use Socket function SELECT to easy check connection state:
"This function determines the status of one or more sockets, waiting if necessary."

if need I can send you more about it function (my email: xansoft13@yahoo.com)
0
edeyCommented:
I havn't used delphi's tcp/ip stuff, simply because I started with FPiette's stuff and didn't see any reason to cahnge :), anyway his *excellent* component suite can be found here:

http://www.rtfm.be/fpiette/indexuk.htm

included is a component that, given an ip, will ping that ip for you.

GL
Mike
0
bryan7Commented:
the best thing you can do is that pc2 notyfies pc1 before closing.. that way pc1 knows pc2 will not be available.
0
cakkCommented:
when pc1 try get data from pc2, if pc2 is already shutdown, pc1 will raise a Exception.
0
ecazanCommented:
You can use API to work with sockets.
You may use function SELECT to easy check connection state:

0
Alisher_NCommented:
by the way, titz!
ping.exe IS 32-bit application, it just works in console mode ;-)

0
titzAuthor Commented:
thanks
for the hint that ping is 32-bit and no dos.
when i call "ping" it works well.
but how can i tell that it
should only do the test with one packet and not four ?
i found no parameter in the help.
because 4 packets take too much time.

Moreover i want to use it in my app.
for this reason can you tell me please,
how i can anlayse the report of "ping"
(it should not be shown on the screen) ??

cheers
titz

0
Alisher_NCommented:
yes, you can call it as external .EXE (I would do internally via sockets...)
if you use 'ping 127.0.0.1 > ping.log' it will save all to file, so you can analyze it later...

for ONE ping use -n1
here are all parameters for ping.exe:


Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
            [-r count] [-s count] [[-j host-list] | [-k host-list]]
            [-w timeout] destination-list

Options:
    -t             Ping the specifed host until stopped.
                   To see statistics and continue - type Control-Break;
                   To stop - type Control-C.
    -a             Resolve addresses to hostnames.
    -n count       Number of echo requests to send.
    -l size        Send buffer size.
    -f             Set Don't Fragment flag in packet.
    -i TTL         Time To Live.
    -v TOS         Type Of Service.
    -r count       Record route for count hops.
    -s count       Timestamp for count hops.
    -j host-list   Loose source route along host-list.
    -k host-list   Strict source route along host-list.
    -w timeout     Timeout in milliseconds to wait for each reply.
0
edeyCommented:
As Alisher_N said, it would prob. be simpler/cleaner to do this with sockets.  For the easiest solution, one would prob. grab a component (such as the one mentioned above) to do this for you.


GL
Mike
0
SteveWaiteCommented:
1/ (tiny bit kludgy)
Have your machine get a mapped drive (\\Mycomp\Myshare = F:\)
of the other and just call DirectoryExists(F:\).  Note this does not work on the root with early versions of delphi so use a known directory in the share.
Also note that since Mapping is explorer function, your check for DirectoryExists() will result in a 5secish delay if the director is not there (but explorer does not pop up a box about it).
I'm looking into a find resources function but is a bit heavy going.
2/If you have D3 with the tcp/ip components then check out the Chat demo provided (~\Borland\Delphi 3\Demos\INTERNET\CHAT).
Theres loads in there and has code you can use to test for ip address using sockets.
3/pester me for EnumNetResources! (not finished yet though)

Steve
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
SteveWaiteCommented:
Of course for your requirement you need to run the check periodically and often enough to give your program some time to do something about it!

Steve
0
titzAuthor Commented:
Well,
after some tests i have the solution for my problem:
i take the point1 from SteveWait. Therefore he shall have the points.
The ping-description from alisher N was helpful, it worked, but it was too slow. But for his help Alisher shall have another 20 points. i will post a new question for him.
the solution with sockets (Borland/demos/...) is possible (and perhaps the "cleanest" solution) and works but is too difficult for programming in a short time.

thanks
and have a nice carnaval !

titz
0
edeyCommented:
hmmmm.....
0
Alisher_NCommented:
to edey:
yes, for me it also looks like a strange choice ;-)
0
SteveWaiteCommented:
Maybe not that professional but if you're in a hurry..
0
Alisher_NCommented:
maybe... the most important thing is that he looks satisfied ;-)
0
SteveWaiteCommented:
That's right! Were all just trying to help.

Nice to meet you folk too...
0
bryan7Commented:
"'m looking into a find resources function but is a bit heavy going. "

I have a demo that shows all the network resources.. pc's connected
mapped drives, etc...
0
SteveWaiteCommented:
stevewaite@compuserve bryan me old mate!
And thanks!
0
bryan7Commented:
just sent..
0
SteveWaiteCommented:
yer lovely!
0
Alisher_NCommented:
bryan! if it's with sources, could you send it to me please: alisher@bcc.com.uz

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
Delphi

From novice to tech pro — start learning today.