473,574 Members | 5,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ping application B from A ?

GTi
I have two .NET 2 applications.
Application A need to check if application B is alive.
How can I do this?
In Win32 I just use PostMessage to B and it posted a message back to A
(no hang)
But I don't want to use pInvoke. Any other way to send a bit between
two application?

Jan 31 '06 #1
9 1551
Did you consider using .NET remoting?
"GTi" <tu****@gmail.c om> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I have two .NET 2 applications.
Application A need to check if application B is alive.
How can I do this?
In Win32 I just use PostMessage to B and it posted a message back to A
(no hang)
But I don't want to use pInvoke. Any other way to send a bit between
two application?

Jan 31 '06 #2
GTi
Yes - but it may be a little heavy for this... (?)
As I know it - it use TCP/IP for communications - then what about
Windows Firewall?

Jan 31 '06 #3
I use named mutex's for this:

1. App B creates a named mutex when it starts, and closes it when it exits
1a. If this fails, a previous instance of App B must already be running...

2. App A attempts to open the named mutex. If the open works, App B is
running.

Hope this helps

Brian.

Jan 31 '06 #4
GTi

Brian C. Barnes wrote:
I use named mutex's for this:

1. App B creates a named mutex when it starts, and closes it when it exits
1a. If this fails, a previous instance of App B must already be running...

2. App A attempts to open the named mutex. If the open works, App B is
running.

Hope this helps

Brian.


Brian,
Looks like what I need!
Can you post a simple samples for this?
Does this work if application B hangs/crash ?
B is is important program and must be running all the time. If not a
message must be sendt to user/support. In this case A check and
displays a warning on screen.

Jan 31 '06 #5
Hello, GTi!

G> Yes - but it may be a little heavy for this... (?)
G> As I know it - it use TCP/IP for communications - then what about
G> Windows Firewall?

If applications are on the same machine then loopback can be used, firewall usually guard external network directions.

You can introduce tcp connection between applications. Then applications will be able to "ping" each other. You can send arbitrary data. The idea here is the connection.

You can also think of named pipes.

You can utilize TcpListener/TcpClient classes to create connection between apps.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Jan 31 '06 #6
Pretty much what Vadym Stetsyak said, although the need for the timer is only
if you want to periodically check to see if app B is still alive. Otherwise,
you can just attempt to open the existing mutex anywhere in your code where
you want to do the "ping".

Brian.

Jan 31 '06 #7
this is kind of hacky, but I have an app which checks to see if another
app needs to be restarted.... due to saids app reliance on an instance
of ie... and ie's love for dieing.

i ended having to use
Process[] all = Process.GetProc esses();

loop over processes looking for mine, if its not there I

Process client = new Process();
client.StartInf o.FileName = this.applicatio nPath;
client.Start();

I also look for possible hangs, by checking said apps output, and
killing it if it appears it needs a restart.

all[x].Kill();

Jan 31 '06 #8
Remoting 2.0 also has an IPC channel.

--
William Stacey [MVP]

"GTi" <tu****@gmail.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
| Yes - but it may be a little heavy for this... (?)
| As I know it - it use TCP/IP for communications - then what about
| Windows Firewall?
|
Jan 31 '06 #9
Hello, mwolf!

m> i ended having to use
m> Process[] all = Process.GetProc esses();

m> loop over processes looking for mine, if its not there I

m> Process client = new Process();
m> client.StartInf o.FileName = this.applicatio nPath;
m> client.Start();

m> I also look for possible hangs, by checking said apps output, and
m> killing it if it appears it needs a restart.

Why is it hacky?
IMO getting process list introduces overhead. Waiting on sync obj is more effective.
However, if the app that you watch for is not yours (you do not have access to its source )
you can use WMI 'query' to look for neede process.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
18189
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include #include #include #include #include #include #include #include #include #include #include #include
0
1320
by: Adam Wayne | last post by:
I am trying to write a ping application that uses multiple threads to ping numerous hosts. I have copied the code from KB 828993 ( http://support.microsoft.com/default.aspx?scid=kb;EN-US;828993 ). This works fine, however I added code to ensure that #1 - the response type is a ping echo (to ensure it wasn't a TTL expired, etc...), and I...
5
5574
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to be executed and then continue pinging another certer. The ping_completed function is called on completion of ping by the os and i have no...
1
18459
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking whether the application is able to access the webservice. If the webservice is accessible, the application is online. otherwise it is offline ...
5
5546
by: Michael M. | last post by:
I have the following code (listed at bottom of post) that pings a small range of IP address to see which ones are alive. To speed things up a little I am trying to use more than one thread, problem is instead of returning: 192.168.0.1 online
2
3950
by: adnanahmed714 | last post by:
hi 1) i am using a home network consisting of two computer.on One pc i have Marvell Lan card(built-in on the board) and on the second pc i have BayLan network adapter. What i know if two pc's are on the same network they ping each other easily.But i my case Pc with Baylan ping the Marvell's Pc but Marvell Pc does not ping the...
8
9807
by: TKowalcz | last post by:
Hello. I have a problem. I need to make a client-server application using sockets (easy). After they communicate server store information about client (IP, and some data). Later on i need to check if the client is connected (ive got his IP and need to ping him). I dont need to write whole ping function - just need a return value :). Ive...
6
3450
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am wondering if anyone has a ping function they could share with me. I have done some searching on this but cannot find anything specifically for vb2003. ...
0
1450
by: SyGC | last post by:
Hi Guys, I have used Threading for Network.Ping to continuously ping an IP address if ping is successful Image A is displayed if not Image B. The code is as follows: Imports System Imports System.Diagnostics Imports System.Threading Public Class Form1
1
72535
by: ScottZ | last post by:
With python 2.6 and wxpython I'm trying to create a system tray icon application based around an example found here: http://codeboje.de/MailSneaker-Part-3-SystemTrayTaskBar-Icons-with-Python-and-wxPython/ The application will simply change the systray icon based on if an ip address is online or not. The ping portion looks like this: if...
0
8259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6491
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5637
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5328
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3763
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3781
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2257
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.