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 5 1781
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
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
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
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
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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?
|
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:
|
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...
|
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...
|
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
| |
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...
|
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...
|
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?
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |