• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

Error 11001 when connecting PPC to PC via WiFi

I'm trying to make a simple chat application between a PPC (Dell Axim x51) and a PC (running Win2K).  When the PPC is connected with ActiveSync (169.254.2.2), it works flawlessly.  When I try to enter it through WiFi (192.168.1.101) it fails using both gethostbyname and gethostbyaddr.  For testing I'm using code taken/adapted from other answers in EE.  Here's my eVC 4 code:

void CCEConnectDlg::OnButton3()
{
      TCHAR szError[100];
      WSADATA wsa;
      struct hostent *pHostent;
      unsigned long ulAddr;
      WSACleanup();
      WSAStartup(MAKEWORD(1,1), &wsa);

      ulAddr = inet_addr("192.168.1.101");
      pHostent = gethostbyaddr((char *)&ulAddr, 4, AF_INET);
      if(pHostent == NULL)
      {
            wsprintf (szError, _T("gethostbyaddr(), \nError: %d"),WSAGetLastError ());
            MessageBox (szError, _T("Error"), MB_OK);
            WSACleanup();
            // try again using gethostbyname
            pHostent = gethostbyname("192.168.1.101");      // Specifying the server by its name;
            if(pHostent == NULL)
            {
                  wsprintf (szError, _T("gethostbyname(), \nError: %d"),WSAGetLastError ());
                  MessageBox (szError, _T("Error"), MB_OK);
            }
      }
      else
      {
            wsprintf (szError, _T("It worked!!! Name: %s"),pHostent->h_name);
            MessageBox (szError, _T("Success"), MB_OK);
      }
      WSACleanup();
      return;      
}

Using 192.168.1.101 ALWAYS results in error 11001, which is WSAHOST_NOT_FOUND.  Can anyone tell me how to make this work?

Thanks,
Paul
0
prstein
Asked:
prstein
  • 2
  • 2
1 Solution
 
Mikal613Commented:
When your connected via wifi can you ping another local address?
0
 
prsteinAuthor Commented:
<Sorry for the delay...>

I downloaded "z2 PocketLAN 3.11", and it appears that I can successfully ping it

Best Regards,
Paul
0
 
Mikal613Commented:
if not mistaken gethostbyaddr is looking for a DNS which means in your host file you have a line which returns a Ip from a string. What you want to accomplish is not possible. Your DNS is not setup.
0
 
prsteinAuthor Commented:
Doh!!!

Instead of using gethostbyaddr I tried filling in a sockaddr_in structure manually.  It all works fine now.  Thanks!

Best Regards,

Paul
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now