473,748 Members | 9,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SocketException from code not caught in try catch or Application_Err or

mc
I have a function (shown below) that I call to check if a server is present. when a server is
present, everything is ok. however when it fails. I get an SocketException fired. On my development
machine all seems to work and the exception is fired and caught. however on my production server the
exception fires, it's not caught by the try catch and it's also not caught in my application_err or
handler in Global.asax. Can anyone shed any light on this?

private bool CheckServer(str ing p){
try{
using (Socket s = new Socket(AddressF amily.Internetw ork, SocketType.Stre am, ProtocolType.Tc p)){
IPEndPoint iep = new IPEndPoint(DNS. GetHostEntry(p) .AddressList[0], 80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}

TIA
MC
Dec 18 '07 #1
5 1783
It might be something to do with the fact that you're using "using" inside a
try block. Try it without the "using".

"mc" <mc@community.n ospamwrote in message
news:47******** @mail.hmgcc.gov .uk...
>I have a function (shown below) that I call to check if a server is
present. when a server is present, everything is ok. however when it fails.
I get an SocketException fired. On my development machine all seems to work
and the exception is fired and caught. however on my production server the
exception fires, it's not caught by the try catch and it's also not caught
in my application_err or handler in Global.asax. Can anyone shed any light
on this?

private bool CheckServer(str ing p){
try{
using (Socket s = new Socket(AddressF amily.Internetw ork,
SocketType.Stre am, ProtocolType.Tc p)){
IPEndPoint iep = new IPEndPoint(DNS. GetHostEntry(p) .AddressList[0],
80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}

TIA
MC

Dec 18 '07 #2
most likely the page request is timing out before the socket connection
timeout. explicity set the values.

-- bruce (sqlwork.com)
"mc" wrote:
I have a function (shown below) that I call to check if a server is present. when a server is
present, everything is ok. however when it fails. I get an SocketException fired. On my development
machine all seems to work and the exception is fired and caught. however on my production server the
exception fires, it's not caught by the try catch and it's also not caught in my application_err or
handler in Global.asax. Can anyone shed any light on this?

private bool CheckServer(str ing p){
try{
using (Socket s = new Socket(AddressF amily.Internetw ork, SocketType.Stre am, ProtocolType.Tc p)){
IPEndPoint iep = new IPEndPoint(DNS. GetHostEntry(p) .AddressList[0], 80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}

TIA
MC
Dec 18 '07 #3
mc
No change! still broke.
Aidy wrote:
It might be something to do with the fact that you're using "using" inside a
try block. Try it without the "using".

"mc" <mc@community.n ospamwrote in message
news:47******** @mail.hmgcc.gov .uk...
>>I have a function (shown below) that I call to check if a server is
present. when a server is present, everything is ok. however when it fails.
I get an SocketException fired. On my development machine all seems to work
and the exception is fired and caught. however on my production server the
exception fires, it's not caught by the try catch and it's also not caught
in my application_err or handler in Global.asax. Can anyone shed any light
on this?

private bool CheckServer(str ing p){
try{
using (Socket s = new Socket(AddressF amily.Internetw ork,
SocketType.St ream, ProtocolType.Tc p)){
IPEndPoint iep = new IPEndPoint(DNS. GetHostEntry(p) .AddressList[0],
80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}

TIA
MC


Dec 18 '07 #4
Hi MC,

It is also likely that there is something related to the account running
the application. Is there any proxy that requires to visit the certain
remote server/site? You can try switch the ASP.NET process to a domain
account to see whether it works.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Tue, 18 Dec 2007 17:26:43 +0000
From: mc <mc@community.n ospam>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Subject: Re: SocketException from code not caught in try catch or
Application_Err or
>
No change! still broke.
Aidy wrote:
>It might be something to do with the fact that you're using "using"
inside a
>try block. Try it without the "using".

"mc" <mc@community.n ospamwrote in message
news:47******* *@mail.hmgcc.go v.uk...
>>>I have a function (shown below) that I call to check if a server is
present. when a server is present, everything is ok. however when it
fails.
>>>I get an SocketException fired. On my development machine all seems to
work
>>>and the exception is fired and caught. however on my production server
the
>>>exception fires, it's not caught by the try catch and it's also not
caught
>>>in my application_err or handler in Global.asax. Can anyone shed any
light
>>>on this?

private bool CheckServer(str ing p){
try{
using (Socket s = new Socket(AddressF amily.Internetw ork,
SocketType.S tream, ProtocolType.Tc p)){
IPEndPoint iep = new
IPEndPoint(DNS. GetHostEntry(p) .AddressList[0],
>>>80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}

TIA
MC


Dec 19 '07 #5
Hi MC,

Have you got progress on this? If still need any help, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Organization : Microsoft
Date: Wed, 19 Dec 2007 09:55:58 GMT
Subject: Re: SocketException from code not caught in try catch or
Application_Err or
>
Hi MC,

It is also likely that there is something related to the account running
the application. Is there any proxy that requires to visit the certain
remote server/site? You can try switch the ASP.NET process to a domain
account to see whether it works.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Dec 21 '07 #6

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

Similar topics

10
3360
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does anybody know how I could do this?
4
11055
by: Amit Yadav | last post by:
Hi, I am trying to write a simple TCP Client Server program which exchange some text messages. Both of my Client and Server are running on the same machine and hence i am using "localhost" when connecting from the client side. However i am getting the following Exception:
13
7579
by: R Reyes | last post by:
is there a way to avoid the validateRequest error page in my code behind file? i can't seem to find a way to handle the error w/o an error code or exception being thrown... i am NOT looking for a link that explains what it does and what it doesn't do OR the pros/cons, as i've already read through many of those. i just want to know if i can code some sort of exception to catch for it so that the ugly yellow/white microsoft generic page...
5
1489
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect page - <customErrors mode="on" defaultRedirect="Error.aspx"/> But how do I reference the exception that occurred from that page? If I cant, then should I use the Application_Error event in global.asax ? And if I do that, then what about hiding...
2
8905
by: James Cooke | last post by:
Hi all, I want to catch a duplicate key exception. I do not want to provide that verbose message from the MSSQL server - I would put a user friendly message out, like "The item you have added already exists in the database. Please change the description and try to save again." instead of
0
3468
by: ZR | last post by:
I am writing two applications which needs to (among other things) communicate through network, so one of them is a client and the other one is a server. I have used asynchronous socket examples found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconblockingclientsocketexample.asp as templates (they have to be asynchronous, because application must not freeze if connection fails). I have converted the...
5
1879
by: stevewilliams2004 | last post by:
I was wondering if someone could explain the output I am getting for the program below. What I expected from the main program output was "Cat" but instead I see "Mammal". The output is also included below. I got the same results with GCC 3.4.4 under cygwin as with MSDev studio 2003. Even stranger to me, if I change the catch statement to catch a Cat instead of a Mammal, the program crashes in the catch body, during the call to...
5
2547
by: jobs | last post by:
re: try catch finally to close and dispose, but still want Application_error to fire 1. If catch an exception to to dispose and close of a ado connect, how can I allow the exception to still trigger my application_error event? 2. And/Or, Is there any way to close and dispose of connections left behind by methods that might have failed without closing connections in the application_error event?
2
1924
by: XenReborn | last post by:
Hi, I wrote a simple socket application, which connects to a simple socket server application I also wrote, the server opens a socket, listens, accepts connections, sends back a string of information and then disconnects. Problem is the client, is the harder to manage, I use blocking mode to receive, after the timeout receive is supposed to throw a socketexception (according to the docs) but it never does... please help me... the code...
0
8991
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
9370
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
9321
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,...
0
8242
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4602
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
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
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
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.