Solved

Winsock error 11004 how to solve it ?

Posted on 2002-05-08
33
14,635 Views
Last Modified: 2013-11-20
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"

NOTE:
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


0
Comment
Question by:vcppmfc
  • 15
  • 12
  • 2
  • +4
33 Comments
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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.
0
 

Author Comment

by:vcppmfc
Comment Utility
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.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
"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.
0
 

Author Comment

by:vcppmfc
Comment Utility
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 http://www.yahoo.com) 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 )
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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!!!
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
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).
0
 

Author Comment

by:vcppmfc
Comment Utility
Hi jhance

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

c:\net send 61.71.80.9 Hi have received my packet

is working fine where as

struct in_addr iaHost;
HOSTENT *pHostInfo = NULL;
iaHost.s_addr = inet_addr("61.71.80.9");
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.

 

0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Again, you don't understand what you are talking about.

1) "NET SEND 61.71.80.9" 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 "61.71.80.9" 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.
0
 

Author Comment

by:vcppmfc
Comment Utility
Yeh i know i got the ip already.Still you have not focused on the problem.My question is how is that NET SEND 61.71.80.9 my message is working fine where as gethostbyaddr(61.71.80.9,...) 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.
0
 

Author Comment

by:vcppmfc
Comment Utility
OR OTHER WISE CAN YOU TELL ME HOW NET SEND WORKS ?
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
"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.
0
 

Author Comment

by:vcppmfc
Comment Utility
>> OR OTHER WISE CAN YOU TELL ME HOW NET SEND WORKS ?

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.
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
>> 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.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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".

Therefore:

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.

0
 

Author Comment

by:vcppmfc
Comment Utility
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 ?

SINCE JAVA APPLICATION IS WORKING FINE , HERE PEOPLE FEAL DNS SERVER CAN'T BE BLAMED.

IS THERE ANY OTHER SOLUTION OTHER THAN BLAMING DNS SERVER ?
0
 

Author Comment

by:vcppmfc
Comment Utility
Snoegler

Can you pl elobrate on nslookup {ip}

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:vcppmfc
Comment Utility
Snoegler

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

c:\nslookup my_machine_ip

i received "non-existent domain" error


0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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"
0
 

Author Comment

by:vcppmfc
Comment Utility
>> 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.

>>SINCE JAVA APPLICATION IS WORKING FINE , HERE PEOPLE >>FEAL DNS SERVER CAN'T BE BLAMED.

>>IS THERE ANY OTHER SOLUTION OTHER THAN BLAMING DNS >>SERVER ?
do you have any answer for this question.

0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
>>Tell where i am resolving IP to hostname ?

gethostbyaddr()
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.
0
 

Author Comment

by:vcppmfc
Comment Utility
>>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

0
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
Comment Utility
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.
0
 

Author Comment

by:vcppmfc
Comment Utility

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.


0
 

Author Comment

by:vcppmfc
Comment Utility
>>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.



0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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!
0
 

Author Comment

by:vcppmfc
Comment Utility
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

import java.net.*

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.

NOTE :
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!
AVOID USING SUCH DISCOURAGING STATMENTS AS THIS IS MEANT FOR SHARING KNOWLEDGE.BE COOL YOU EFFORTS WILL BE AWARDED SOON ,ALL THE BEST.
0
 
LVL 2

Expert Comment

by:wyy_cq
Comment Utility
if u only want to connect to svr
u need not call that
skip it and call connect
0
 

Author Comment

by:vcppmfc
Comment Utility
Hi wyy_cq:

Pl elobrate with codings
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Sorry,

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!
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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 Register.com 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
0
 
LVL 11

Expert Comment

by:griessh
Comment Utility
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
Comment Utility
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now