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_error
handler in Global.asax. Can anyone shed any light on this?
private bool CheckServer(string p){
try{
using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){
IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80);
s.Connect(iep);
return true;
}
}
catch{
return false;
}
}
TIA
MC 5 1767
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.nospamwrote 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_error handler in Global.asax. Can anyone shed any light on this?
private bool CheckServer(string p){
try{
using (Socket s = new Socket(AddressFamily.Internetwork,
SocketType.Stream, ProtocolType.Tcp)){
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_error
handler in Global.asax. Can anyone shed any light on this?
private bool CheckServer(string p){
try{
using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){
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.nospamwrote 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_error handler in Global.asax. Can anyone shed any light on this?
private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ 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.nospam> Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Re: SocketException from code not caught in try catch or
Application_Error
> 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.nospamwrote 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_error handler in Global.asax. Can anyone shed any
light
>>>on this?
private bool CheckServer(string p){ try{ using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){ 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_Error
> 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...
|
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"...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |