473,803 Members | 3,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting loss of network

I am using the following code to monitor a socket port. The code normally
works fine unless a network connection is lost. Since both ends of the
conversation on the same computer (normally) this causes a problem because
they can no longer connect. On my system if the network is reconnected the
two system can start communicating again but on other systems I am told they
can not.

One program is a service and the other is the user interface which is why I
am doing this.

So the questions:

1) Is there a way of handling this so a loss of the network connection does
not drop the connect when both programs are on the same system?

2) Is there anyway for the listener to determine that the network connect
has been lost?

3) In the latest version of .NET have them implemented memory pipes yet?

Regards,
John
CODE:

IPHostEntry ipHostInfo = Dns.GetHostEntr y(Dns.GetHostNa me());
foreach(IPAddre ss ipAddress in ipHostInfo.Addr essList)
{
try
{
int ConnectionPort = (int)Utils.Misc Funs.ReadRegDat a(false, "Socket",
"Monitor Port", 12000);
int MaxThrds = (int)Utils.Misc Funs.ReadRegDat a(false, "Socket", "Max
Threads", 5);

IPEndPoint localEndPoint = new IPEndPoint(ipAd dress, ConnectionPort) ;
if (localEndPoint. AddressFamily == AddressFamily.I nterNetwork)
{
Socket listener = new Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p);
listener.Bind(l ocalEndPoint);
listener.Listen (MaxThrds);
this.ListenerLi st.Add(listener );
}
}
catch(System.Th reading.ThreadA bortException abEx)
{
throw abEx;
}
catch(Exception ex)
{
this.onExceptio n(ex);
System.Diagnost ics.Debug.Write Line("Monitor Thread (IPAddress)" +
ex.Message);
}
}
while(this.IsRu n)
{
try
{
ArrayList tmpPortList = new ArrayList();
foreach(object o in this.ListenerLi st)
tmpPortList.Add (o);

if(tmpPortList. Count > 0)
{
Socket.Select(t mpPortList, null, null, 1000);
foreach(object o in tmpPortList)
{
Socket s = ((Socket)o).Acc ept();
/// start thread to do something
}
}
}
catch(System.Th reading.ThreadA bortException abEx)
{
throw abEx;
}
catch(Exception ex)
{
this.onExceptio n(ex);
System.Diagnost ics.Debug.Write Line("Monitor Thread (IPAddress2)" +
ex.Message);
}
}
Mar 29 '06 #1
0 1364

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

Similar topics

4
2190
by: Michael Albanese | last post by:
I am trying to build a user control that will allow a user to select a date from a calendar. I have to code that will run on the calendar's SelectionChanged event, but i am at a loss to return the data to the correct text box. The question is...How do I detect the Form Name programatically from a user control that is included on a page. i.e. - me.formname....? Thanks in advance for any help.
3
465
by: Sandeep Arya | last post by:
Thanks linuxfreak and sybren for positive comments My application will be running on Linux. How to send ICMP ECHO as broadcast packets. I do not know this. Please tell me how to? Sybren.. Does nmap is available on every systems? I tried on my linux fc4 machine in user previleage. it was not working. Does this just belongs to superuser...
0
1547
by: sid | last post by:
Data loss in Access-97 from VB 6.0 I have encountered Random data loss in our access database. Sometimes the users call in saying that the records entered by them are lost. The users, use our VB front end to enter the data (Users do not enter data directly into the database) Most of the times I have noticed that the problem occurs when users add new records. All our tables have a unique alpha-numeric primary key.
2
1674
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is being allocated for the entire site (since the site acts as one big application.) Is there anyway to do this through code? The reason I ask is because occasionally, our site will start having session state loss. After a day or two, it goes back...
4
2766
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been lost and show an explanatory message before restarting the session. Rather than tagging a 'session in progress' flag on the end of every request querystring I'd like to detect it using data sent in every request. One idea I had was that when...
3
10299
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not available...)? Are there any strategies to detect this broken connections, and how can I
2
2431
by: =?Utf-8?B?TVNXaW5kb3dzUHJvZg==?= | last post by:
hi, We are trying to figure out a way of detecting any incoming http request, to our ASP.NET 2.0 application, if it is coming from our internal network (intranet) vs from outside of our network(internet). We can get the client machine's ip from the http request, but is there any way of validating if the ip is a intranet ip vs. an internet ip? Our intranet is pretty large, spans over a WAN with multiple subdomains. Any information/pointer...
1
1868
by: rajeshrocks2006 | last post by:
Hi, i need help in detecting usb port in a network and have to provide authentication for the USB port for the system security purposes...plzz help me....
3
1473
by: limperger | last post by:
Hello! This is quite important. We have an Access file shared in a network. Every user has its front-end copy that is linked to a back-end copy. This database has an autonumber field to count the records. Surprisingly, one day we found out that the autonumber count had elapsed 500 records; that is, the last entered record was assigned number 650 and the new one was assigned number 1100 by the autonumber field. I didn't find any...
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10310
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10292
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7603
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5498
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.