Winsock error 11004 how to solve it ?

I have machine A and machine B runing win-2000 and they are independent.Machine A is connected to the Internet through my service provide("Dishnet" phno-172341) by dial up connection same way Machine B is connected to Internet through the same service provide(let say another account phno-8210021).I have an socket server watching at port 1200 which is at Machine A.I have client socket at machine B connecting to server(to Machine A) at port 1200.Now comming to the problem

the client is started in Machine B like this

c:\client.exe 1200 ip_add_of_machine_A host_name

i have used

struct in_addr iaHost;
HOSTENT *pHostInfo = NULL;
iaHost.s_addr = inet_addr(ip_add_of_machine_A);
pHostInfo = gethostbyaddr((LPCTSTR)&iaHost,sizeof(struct in_addr),AF_INET);

if(pHostInfo == NULL)
     ReturnError(WSAGetLastError());// just displays  error message
     return 0;

i get an winsock error 11004 the error discription is

"The requested name is valid and was found in the database,but it does not have have correct associated data being resolved for"

Machine A and B does not have static ip but the service provider provide dynamic ip for Machine A and B which i use it.

kindly give me a solution ASAP.

Thank you

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There is no guarantee that gethostbyaddr() will ever work.  This is a REVERSE DNS address -> hostname resolution but whether it works or not depends on the DNS database entries for the IP block in which the IP address belongs.

My guess here is that there is NO associated reverse DNS (RDNS) lookup entry in the DNS database.  

Talk to your network provider.
vcppmfcAuthor Commented:
hi considering my case as questioned above if i net send a message from Machine B as below

c:\net send dynamic_ip_of_Machine_A hi got the msg

i am able to receive the message in Machine B . net send process is able to resolve the dynamic ip to static ip How ? It has to definitely contact my ISP and how it resolves the ip from its DNS database. Solution pls.
"dynamic ip to static ip"

?????  You're talking in circles here.  IP is IP, there is no difference between a dynamic ip and a static ip once it's been set.

DNS resolves HOSTNAMES to IP address or IP address to HOSTNAME.  There is no need to resolve an IP to an IP.  That's ridiculous.

Have you considered getting a basic Windows network programming book?  It seems to me you're trying to do something but lack an understanding of even the basic concepts.  I like Lewis Napper's WINSOCK 2.0 as both a good into to network programming and a great reference for Windows network programming.  But this is by no means the only good book out there.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

vcppmfcAuthor Commented:
hello friend

I am not asking you to suggest books i ask you the solution for the problem (Winsock error number 11004 ).I did not mean about resolving ip, why do i get 11004 error when i use dynamic ip and i don't get this error when i use static ip? this is the question i am seeking answere for.
We have two machines A and B which does not have static ip(which means that we have not registered any domain name) and therefore our ISP will offer dynamic ip( this ip is valid only for particular session and not permanent that why we call it dynamic ip) whenever we connect our machines to the internet now this dynamic ip becomes static ip(only valid for this session) by which any host can recoganize our machine.

with this ip i am able to ping both the machines and i am able to use net send to send messages.

Now the question is gethostbyaddr(...) works fine when i pass any static ip( let us ip of but when i pass dynamic ip (the ip which my ISP has offered) the function returns NULL (Winsock error number 11004 )pointer why?

you may suggest any other methods to solve (Winsock error number 11004 )
You're STILL talking in circles here.  IP is IP, there is no difference between a dynamic ip and a
static ip once it's been set.

My guess here is that there is NO associated reverse DNS (RDNS) lookup entry in the DNS database.  

Talk to your network provider.

The problem is NOT with your programming, it's with your DNS SERVER!!!!  

Read my lips, your DNS SERVER IS THE PROBLEM!!!
jhance is right. You can simply try if the IP you want to lookup is 'lookup-able'. Enter this is a console window:

nslookup {ip}

If you get a 'non-existent domain' error, you will never ever be able to resolve the IP (dynamic or static, doesn't matter) (as long as it is not just a temporary failure).
vcppmfcAuthor Commented:
Hi jhance

Its OK but my net send is working how.Let us say my host IP is then

c:\net send Hi have received my packet

is working fine where as

struct in_addr iaHost;
HOSTENT *pHostInfo = NULL;
iaHost.s_addr = inet_addr("");
pHostInfo = gethostbyaddr((LPCTSTR)&iaHost,sizeof(struct in_addr),AF_INET);

if(pHostInfo == NULL)
    ReturnError(WSAGetLastError());// just displays  error message
    return 0;

does not work why "net send" should also contact my DNS.
If you say the problem is with my DNS SERVER!!!!  then how come "net send" is working is there any other way for this problem.

NOTE: I am using winsock.dll version-3.10 and it is 16-bit as refered by its properties.


Again, you don't understand what you are talking about.

1) "NET SEND" does NOT need DNS.  The IP address is already specified!!!!!!  THat's waht I've been trying to tell you.  DNS resolves HOSTNAMES to IP addresses or IP addresses to HOSTNAMES.  You HAVE an IP address and WANT an IP address.  No need to call ANY DNS resolver.

2) In your code snippet, the gethostbyaddr() can fail, and you say it does fail.  The error you are getting means that your DNS server DOESN'T KNOW WHAT HOSTNAME IS ASSOCIATED WITH THE IP ADDRESS!!!!!  Read my lips, IT DOESN'T KNOW!  It cannot tell you things it doesn't know.  Let me repeat, the DNS cannot tell you things it doesn't know.  Got it?

But again WHY are you trying to lookup the HOSTNAME from the IP?  This is rarely required and is only sometimes useful.  The gethostbyaddr() is a much less commonly used function than the gethostbyname() resolver.

I think (that means I'm only guessing) that what you REALLY want to use here is the inet_addr() function.  I'm guessing because you've said NOTHING about what you're trying to do AFTER you resolve this "IP".

inet_addr() takes a "dotted" IP address string like "" and converts it into a packed format that is used by most of the other sockets functions that take an IP address.

Again, I STRONGLY suggest you get yourself a basic network programming/sockets book.  You are missing even the basic concepts here and in spite of my trying you continue to ignore sound advice and keep asking the same stuff over and over.
vcppmfcAuthor Commented:
Yeh i know i got the ip already.Still you have not focused on the problem.My question is how is that NET SEND my message is working fine where as gethostbyaddr(,...) does n't work ?
I know since iam passing ip there is NO NEED FOR RESOLVING.I wan you to focus on this simplified question rather than draging the discussion so that you will be awarded soon.
vcppmfcAuthor Commented:
"NET SEND" was not in your question at all!

You asked WHY error 11004 is returned by gethostbyaddr().

The answer to this question is given.

Asking how NET SEND works is an entirely different and unrelated question.
vcppmfcAuthor Commented:

Can you see the word "OR" this question have been asked only to enable you to thing from other angles too, since you found difficult to focuse on the problem.

>>Read my lips, your DNS SERVER IS THE PROBLEM!!!

This is not the solution for this problem.People here have not encountered any DNS SERVER PROBLEM to use their internet applications.This answer can not be considered as an experts answer.
>> since you found difficult to focuse on the problem.
The only one being unfocused here is you.

>> here have not encountered any DNS SERVER PROBLEM to
You should really read a book on networking. You really have not even a basic concept of what you're asking.

Sorry for being rude, but i'd suggest taking a look at the question history of 'jhance'. Then i'd suggest taking a look into your history. Then you'll find that you're pretty new here and should think twice before accusing someone here of not understanding the question.
Let me rephrase:

You are asking your DNS server a question which it CANNOT answer.  That's what this error code means, it's the DNS server's way of saying "I don't know".


1) It's a improperly configured server.
2) It's a bad question you are asking.

OK?  You choose!  Either fix the DNS server or ask a question that it is able to answer, but remember that NOT ALL QUESTIONS HAVE AN ANSWER.  And the reverse IP lookup is one such question. NOT ALL IP addresses have a hostname.

NET SEND has NOTHING to to with DNS and in fact, is a Microsoft proprietary application.  While I don't have the source code (but I do think source code to it or something similar is available in the SDK samples) I don't believe that it even uses SOCKETS directly.  I'm pretty sure it's a NETBIOS application.  NETBIOS only uses TCPIP (i.e. sockets) under very specific circumstances, which I'd explain for you but which I'm sure you'd not understand.

vcppmfcAuthor Commented:
We have already internet enabled java client server application which is working fine it uses same ISP.My task is to use Winsock and create similar application.

Can DNS server behave differently for Java socket class and winsock ?


vcppmfcAuthor Commented:

Can you pl elobrate on nslookup {ip}

vcppmfcAuthor Commented:

just now (15-5-2002 8:00 pm) i executed the command

c:\nslookup my_machine_ip

i received "non-existent domain" error

It's the SAME answer as what you get from gethostbyaddr()!!

Your DNS server doesn't know the hostname associated with whatever IP you gave it.
Again, WHY are you trying to resolve an IP address to a hostname?  It's NOT NECESSARY!  

The answer you are getting is: "there is no hostname associated with that IP address"
vcppmfcAuthor Commented:
>> Again, WHY are you trying to resolve an IP address to a hostname?  It's NOT NECESSARY!  

>>Again, WHY are you trying to resolve an IP address to a >>hostname?  It's NOT NECESSARY!  

Tell where i am resolving IP to hostname ?

I do not have any IP to be resolved.

>>Can DNS server behave differently for Java socket class and winsock ?
do you have any answer for this question.


do you have any answer for this question.

>>Tell where i am resolving IP to hostname ?

c:\nslookup my_machine_ip

Both of these attempt to resolve your IP to a hostname. STOP IT!

There is no way you are going to be able to complete this project:

1) You know next to nothing about network programming.
2) You refuse to learn anything new.
3) You can't understand simple statements.

I'm sorry, I'm completely tired of you and this question.  Perhaps there are other experts who have some magic solution to your situation.

Good bye.
vcppmfcAuthor Commented:
>>There is no way you are going to be able to complete >>this project:

I have found an Alternative solution for this problem. That is what i have expected from you.Inspite of DNS SERVER PROBLEM(is the onely solution you gave) i found an alternative solution.Thank you

Please award me the points.  In spite of your refusal to accept sound advice, the advice given was still correct and applicable to your original question.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vcppmfcAuthor Commented:

I didn't gain any thing after having lengthy discussion with you since you try to find fault on the question rather than providing alternative solution.

It could also me my mistake to make you understand my question.

You have not provided any alternative solution inspite of repeated request.And therefore i have found out an alternative solution myself and it works fine.Even before you have adviced i have already strated to gain information about Winsock.If you still have any alternative solution you are welcomed.

vcppmfcAuthor Commented:
>>Read my lips, your DNS SERVER IS THE PROBLEM!!!

I am not able to accept this answer because our Java internet enabled client/server application is working fine.We are you using java socket classes in this application.We just pass the IP provide by our ISP and port no in order to connect our java client/server application it works fine.I have been given the same task to be done with Winsock.

Had our java socket application not worked properly then you answer will carry more weightage.

Alright then, show both your complete JAVA code and your C++ code.  Give the ACTUAL IP address and the DNS server you are using.

Enough of your theoretical baloney.  Put up or shut up!
vcppmfcAuthor Commented:
I can give you my CPP code but JAVA code is handled by different team , and the code is kept confidential.But i can give you necessary information how they have used sockets.

The JAVA package used is

JAVA version -1.4


Server Application:
1 ServerSocket serverObj = new ServerSocket(nPortNo);
  serverObj.accept();// accept the client connection

Client Application:
2 Socket socketObj = new Socket("localhost",nPortNo);
  // some I/O streams operations

If you can give your e-mail id i can post my ziped CPP code.

My project requirement is that my socket server/client app should work for static IP as in real implemetation our client is going to use only static IP.

But i have taken special interest that my socket server/client app should even work for dynamic IP and thats were i FAILED.But i have over come this failure my finding an alternative solution.

>> Enough of your theoretical baloney.  Put up or shut up!
if u only want to connect to svr
u need not call that
skip it and call connect
vcppmfcAuthor Commented:
Hi wyy_cq:

Pl elobrate with codings

As with you, everything is confidential!

Code your application properly and it will work

You still don't understand the meaning of WINSOCK error 11004.  The comments made in this question thread address the problem completely.  READ the comments, UNDERSTAND the comments, LEARN!
Hi vcppmfc,
I think I can clear the air here (it's pretty stinky right now):

There is NO host name associated with a dynamic IP.  Try using the TRACERT utility to see the route between your computer and a dynamic IP number.  There will be several nodes along the route that have names and several that do not.  The ones that do not have failed the gethostbyaddr request that was made by TRACERT.

The final node is fully accessible via its IP NUMBER but that IP number is not associcated with a registered HOST NAME.  There will never be a host name associated with that IP number until it is registered with or other such service (something that is not allowed since your ISP owns the block of IP numers that it gives out dynamically).

In such cases, you can just use the IP number as if it were a host name.  That is what the JAVA program is doing... just using the IP NUMBER, never a host name.

-- Dan
Dear vcppmfc

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jhance" (well-earned points I might say !!!!!)

comment(s) as an answer.

Force accepted

** Mindphaser - Community Support Moderator **
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.