Link to home
Start Free TrialLog in
Avatar of titz
titz

asked on

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
Avatar of edey
edey

you could ping the other computer


GL
Mike
edy, simple yet effective :)

Does Delphi 3 have built in TCP IP like D4?


Craig C.
oops, i mean edey AKA Mike
some versions of d3 do, mine (standard) does not :(.  Anyway, FPiettes comp's are really good :).

Gl
Mike
Avatar of titz

ASKER

how can a ping ?

cheers
titz
Avatar of titz

ASKER

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
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)
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
the best thing you can do is that pc2 notyfies pc1 before closing.. that way pc1 knows pc2 will not be available.
when pc1 try get data from pc2, if pc2 is already shutdown, pc1 will raise a Exception.
You can use API to work with sockets.
You may use function SELECT to easy check connection state:

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

Avatar of titz

ASKER

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

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.
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
ASKER CERTIFIED SOLUTION
Avatar of SteveWaite
SteveWaite

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of titz

ASKER

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
hmmmm.....
to edey:
yes, for me it also looks like a strange choice ;-)
Maybe not that professional but if you're in a hurry..
maybe... the most important thing is that he looks satisfied ;-)
That's right! Were all just trying to help.

Nice to meet you folk too...
"'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...
stevewaite@compuserve bryan me old mate!
And thanks!
just sent..
yer lovely!
bryan! if it's with sources, could you send it to me please: alisher@bcc.com.uz