Winsock problem 
Author Message
 Winsock problem

Dear All:

I wrote a test program to create a winsock client under
WinCE .Net 4.1 ,I use Intel XScale 255 for development,
but I always get "NULL hosent" when I use "gethostbyname
()" or "gethostbyaddr()", does anyone knows the problem?

The WSAGetLastError() returns the error
code "WSAHOST_NOT_FOUND".

I've configed the DNS server for my CE platform.
The code works fine in my windows 2000.

Void MyProc(){
struct hostent *hp;
unsigned long addr;
        if ((status = WSAStartup(MAKEWORD(1,1), &WSAData))
== 0) {
                Write_Log("Program ok!\n");
        }else{
                Write_Log("Program Fail!\n");
                WSACleanup();
                return ;
        }
hp = gethostbyaddr((const char *)&addr,4,AF_INET);

//addr = inet_addr("192.168.1.21");
//hp = gethostbyaddr((const char *)&addr,4,AF_INET);

//hp always be NULL
//WSAGetLastError() return WSAHOST_NOT_FOUND
// But the code works fine under windows 2000/NT

Quote:
}

Best Regards,
mjwang


Sun, 25 Sep 2005 16:51:17 GMT  
 Winsock problem
Well, when you're asking for a host based on an address, you actually have
to *set* the address to something.  Note that addr is uninitialized in your
code.

Paul T.


Quote:
> Dear All:

> I wrote a test program to create a winsock client under
> WinCE .Net 4.1 ,I use Intel XScale 255 for development,
> but I always get "NULL hosent" when I use "gethostbyname
> ()" or "gethostbyaddr()", does anyone knows the problem?

> The WSAGetLastError() returns the error
> code "WSAHOST_NOT_FOUND".

> I've configed the DNS server for my CE platform.
> The code works fine in my windows 2000.

> Void MyProc(){
> struct hostent *hp;
> unsigned long addr;
> if ((status = WSAStartup(MAKEWORD(1,1), &WSAData))
> == 0) {
> Write_Log("Program ok!\n");
> }else{
> Write_Log("Program Fail!\n");
> WSACleanup();
> return ;
> }
> hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> //addr = inet_addr("192.168.1.21");
> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> //hp always be NULL
> //WSAGetLastError() return WSAHOST_NOT_FOUND
> // But the code works fine under windows 2000/NT
> }

> Best Regards,
> mjwang



Mon, 26 Sep 2005 00:27:02 GMT  
 Winsock problem
Okay, I made something mistake,
The marked codes:
//addr = inet_addr("192.168.1.21");
//hp = gethostbyaddr((const char *)&addr,4,AF_INET);
I tried is still not work, the ip-address "192.168.1.21"
is the server's ip of UDP socket, my test client is
at "192.168.1.30".
Even I tried the function "gethostbyname()", the error
code is the same, does any one have any idea?

Thanks in advance.

Best Reagrds,
mjwang

Quote:
>-----Original Message-----
>Well, when you're asking for a host based on an address,
you actually have
>to *set* the address to something.  Note that addr is

uninitialized in your
Quote:
>code.

>Paul T.



>> Dear All:

>> I wrote a test program to create a winsock client under
>> WinCE .Net 4.1 ,I use Intel XScale 255 for development,
>> but I always get "NULL hosent" when I use "gethostbyname
>> ()" or "gethostbyaddr()", does anyone knows the problem?

>> The WSAGetLastError() returns the error
>> code "WSAHOST_NOT_FOUND".

>> I've configed the DNS server for my CE platform.
>> The code works fine in my windows 2000.

>> Void MyProc(){
>> struct hostent *hp;
>> unsigned long addr;
>> if ((status = WSAStartup(MAKEWORD(1,1), &WSAData))
>> == 0) {
>> Write_Log("Program ok!\n");
>> }else{
>> Write_Log("Program Fail!\n");
>> WSACleanup();
>> return ;
>> }
>> hp = gethostbyaddr((const char *)&addr,4,AF_INET);

>> //addr = inet_addr("192.168.1.21");
>> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);

>> //hp always be NULL
>> //WSAGetLastError() return WSAHOST_NOT_FOUND
>> // But the code works fine under windows 2000/NT
>> }

>> Best Regards,
>> mjwang

>.



Mon, 26 Sep 2005 11:02:58 GMT  
 Winsock problem
All that means is that reverse address resolution doesn't work in your
network environment.  The CE system couldn't find anyone to ask what name to
use for "192.168.1.21".  For what are you using this process?  It's rather
like taking the IP address that corresponds to www.microsoft.com and calling
gethostbyaddr() on that.  Why would you do it?

Paul T.


Quote:
> Okay, I made something mistake,
> The marked codes:
> //addr = inet_addr("192.168.1.21");
> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);
> I tried is still not work, the ip-address "192.168.1.21"
> is the server's ip of UDP socket, my test client is
> at "192.168.1.30".
> Even I tried the function "gethostbyname()", the error
> code is the same, does any one have any idea?

> Thanks in advance.

> Best Reagrds,
> mjwang

> >-----Original Message-----
> >Well, when you're asking for a host based on an address,
> you actually have
> >to *set* the address to something.  Note that addr is
> uninitialized in your
> >code.

> >Paul T.



> >> Dear All:

> >> I wrote a test program to create a winsock client under
> >> WinCE .Net 4.1 ,I use Intel XScale 255 for development,
> >> but I always get "NULL hosent" when I use "gethostbyname
> >> ()" or "gethostbyaddr()", does anyone knows the problem?

> >> The WSAGetLastError() returns the error
> >> code "WSAHOST_NOT_FOUND".

> >> I've configed the DNS server for my CE platform.
> >> The code works fine in my windows 2000.

> >> Void MyProc(){
> >> struct hostent *hp;
> >> unsigned long addr;
> >> if ((status = WSAStartup(MAKEWORD(1,1), &WSAData))
> >> == 0) {
> >> Write_Log("Program ok!\n");
> >> }else{
> >> Write_Log("Program Fail!\n");
> >> WSACleanup();
> >> return ;
> >> }
> >> hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> >> //addr = inet_addr("192.168.1.21");
> >> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> >> //hp always be NULL
> >> //WSAGetLastError() return WSAHOST_NOT_FOUND
> >> // But the code works fine under windows 2000/NT
> >> }

> >> Best Regards,
> >> mjwang

> >.



Tue, 27 Sep 2005 04:38:26 GMT  
 Winsock problem
The best thing to do would be to use Network Monitor on a Windows NT/XP
machine to sniff the packets you're sending and receiving.  You could post
the capture to the newsgroup or you may be able to figure out the problem
yourself.

You can get Microsoft Network Monitor by purchasing SMS or you can download
a 3rd party packet sniffer such the one here:
http://www.analogx.com/contents/download/network/pmon.htm (I've never used
the one at this link personally)

It's probably one of three things: (1) the reverse resolution request is
never sent and there's some local problem, (2) the DNS server isn't seeing
the reverse resolution request, (3) the DNS server sees the request and
sends back a failure response.

-Corey


Quote:
> Okay, I made something mistake,
> The marked codes:
> //addr = inet_addr("192.168.1.21");
> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);
> I tried is still not work, the ip-address "192.168.1.21"
> is the server's ip of UDP socket, my test client is
> at "192.168.1.30".
> Even I tried the function "gethostbyname()", the error
> code is the same, does any one have any idea?

> Thanks in advance.

> Best Reagrds,
> mjwang

> >-----Original Message-----
> >Well, when you're asking for a host based on an address,
> you actually have
> >to *set* the address to something.  Note that addr is
> uninitialized in your
> >code.

> >Paul T.



> >> Dear All:

> >> I wrote a test program to create a winsock client under
> >> WinCE .Net 4.1 ,I use Intel XScale 255 for development,
> >> but I always get "NULL hosent" when I use "gethostbyname
> >> ()" or "gethostbyaddr()", does anyone knows the problem?

> >> The WSAGetLastError() returns the error
> >> code "WSAHOST_NOT_FOUND".

> >> I've configed the DNS server for my CE platform.
> >> The code works fine in my windows 2000.

> >> Void MyProc(){
> >> struct hostent *hp;
> >> unsigned long addr;
> >> if ((status = WSAStartup(MAKEWORD(1,1), &WSAData))
> >> == 0) {
> >> Write_Log("Program ok!\n");
> >> }else{
> >> Write_Log("Program Fail!\n");
> >> WSACleanup();
> >> return ;
> >> }
> >> hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> >> //addr = inet_addr("192.168.1.21");
> >> //hp = gethostbyaddr((const char *)&addr,4,AF_INET);

> >> //hp always be NULL
> >> //WSAGetLastError() return WSAHOST_NOT_FOUND
> >> // But the code works fine under windows 2000/NT
> >> }

> >> Best Regards,
> >> mjwang

> >.



Wed, 28 Sep 2005 07:23:24 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. winsock problem

2. Help! Winsock problems

3. Winsock problem

4. Winsock problems...

5. Winsock problem

6. Winsock problems

7. 16bit WinSock Problem

8. Winsock Problem!!! Can't utilize in multithread

9. Winsock Problem!!! Can't utilize in multithread

10. MS Winsock Problems (using CAsyncSocket to open/connect/close)

11. serious WinSock Problem

12. Winsock problem

 

 
Powered by phpBB® Forum Software