HttpWebRequest
과 관련된 문제가 있습니다. WebService가있는 서버와 CF 2.0 클라이언트가있는 Windows CE 6.0 사이의 연결을 관리하려고합니다. 실제 목적은 Windows CE 컴퓨터의 외부 IP를 검색하는 것입니다. 나는 HttpWebResponse
을 사용하려고했지만 통화 도중 멈춰 버립니다.HttpWebResponse가 응답하지 않습니다.
private string GetIPAddressRemote()
{
Uri validUri = new Uri("http://icanhazip.com");
try
{
string externalIP = "";
HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(validUri);
httpRequest.Credentials = CredentialCache.DefaultCredentials;
httpRequest.Timeout = 10000; // Just to haven't an endless wait
using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())
/* HERE WE ARE
* In this point my program stop working...
* well actually it doesn't throw any exception and doesn't crash at all
* For that reason I've setted the timeout property because in this part
* it starts to wait for a response that doesn't come
*/
{
using (Stream stream = httpResponse.GetResponseStream())
{
// retrieve the return string and
// save it in the externalIP variable
}
}
return externalIP;
}
catch(Exception ex)
{
return ex.Message;
}
}
그래서, 내 문제가 무엇 :
가 지금은 더 명확하게 할 것, 그게 내가이 IP를 얻기 위해 주춤 컴퓨터에서 실행하고있어 코드는? 나는 왜 그것이 httpRequest.GetResponse()
전화, 어떤 생각하는 동안 붙어 있는지 모르겠다? 나는 프록시하에 있다고 말했기 때문에 프록시가 일부 요청을 차단했다는 생각이 들었다.
목표가 서버 IP 주소를 얻는 것이라면 DNS를 사용하여 호스트 이름 확인을 시도 할 수 있습니다. 그렇지 않으면 WebRequest 대신 ping을 실행하고 거기에서 IP를 얻는 것이 더 쉽습니다. – salvolds
아니요, 제 목표는 서버에 연결된 시스템의 IP를 얻는 것입니다. 어쨌든 이제 나는 기계와 서버 사이의 연결을 얻고 서버와 다른 PC 사이의 연결을 얻는 또 다른 경로를 찾으려고합니다. –