Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

gethostbyname blocking timeout

Posted on 1998-05-19
6
Medium Priority
?
1,510 Views
Last Modified: 2013-12-03
I have a Windows NT Workstation 4.0 where I use some socket applications.  There is WINS configured. The applications call the "gethostbyname()" socket function to discover the addresses of the servers.
Sometimes, the network adapter or the cable can be damaged or disconnected in my environment. When it occurs, my applications wait about 3 minutes blocked in the "gethostbyname()" socket api before the error is detected.
I wouldn't like to replace that api by WSAAsyncGetHostByName( ).
Does it exist a way I could use to reduce that timeout ?
Would it be manageable using registry ?
0
Comment
Question by:edsont
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1402686
What's wrong with WSAAsyncGetHostByName()?

Oh, well...  You can use WSACancelBlockingCall() to cancel the call.  You can use WSASetBlockingHook() to install your own blocking hook.

I'd suggest running gethostbyname() in one thread while another thread waits on a timer and cancels the call on expiry.  Another sulotion is installing a blocking hook before calling gethostbyname(), that will exit after a specified amount of time.

0
 

Author Comment

by:edsont
ID: 1402687
My problem is that I really wouldn't like to modify a lot my aplication.
To tell you the truth, I've implemented it as a library function and it is being used in some customers. One of the customers has complained that when there is a problem like a disconnected twisted pair, his application holds for about 3 minutes in my library. I've tested my library and discovered that the "gethostbyname( )" api waits that amount of time in that situation.

I think the best solution would be modifying a "find server address" timeout parameter in the registry, if it exists.

0
 
LVL 11

Accepted Solution

by:
alexo earned 60 total points
ID: 1402688
There are several registry parameters that affect TCP/IP, DNS and WINS timeouts and retransmissions (I've included a list below).  You're probably sufferring from more than one.  Note however that these parametres can affect other timing issues.

I suggest you start with "WinsDownTimeout" and continue with other arguments.

Entries for TCP/IP Parameters.   This subkey is located in following Registry path:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters

DefaultTTL     REG_DWORD
Range: Seconds:      1 - 255
Default: 128
Specifies the default Time To Live (TTL) value set in the header of outgoing IP packets. The TTL determines the maximum amount of time an IP packet can live in the network without reaching its destination. This value acts as a limit on the number of routers an IP packet can pass through before being discarded.

TcpMaxConnectRetransmissions     REG_DWORD
Range: 0 - 0xFFFFFFFF
Default: 3
Determines the number of times TCP will retransmit a connect request (SYN) before aborting the attempt. The retransmission time-out is doubled with each successive retransmission in a given connect attempt. The initial time-out value is three seconds.

TcpMaxDataRetransmissions     REG_DWORD
Range: 0 - 0xFFFFFFFF
Default: 5
Determines the number of times TCP will retransmit an individual data segment (nonconnect segment) before aborting the connection. The retransmission time-out is doubled with each successive retransmission on a connection. It is reset when responses resume. The base time-out value is determined dynamically by measuring the round-trip time of the connection.

KeepAliveInterval     REG_DWORD
Range: 1 - 0xFFFFFFFF milliseconds
Default: 1000  (1 second)
Determines the interval between keep-alive retransmissions until a response is received and, once a response is received, determines the delay until the next keep-alive transmission. The connection will be aborted after the number of retransmissions specified by TcpMaxDataRetransmissions have gone unanswered.


The NetBt\Parameters subkey contains value entries for NetBt (NetBIOS over TCP/IP) common to all NetBt services. This subkey is located in following Registry path:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBt\Parameters

LmhostsTimeout     REG_DWORD
Range: 1000 - 0xFFFFFFFF milliseconds
Default: 6000 (6 seconds)
Specifies the time-out value for LMHOSTS and DNS name queries. The timer has a granularity of the time-out value, so the actual time-out could be as much as twice the value.

NameSrvQueryCount     REG_DWORD    
Range: 0 - 0xFFFF
Default: 3
Determines the number of times NetBT sends a query to a WINS server for a given name without receiving a response.

NameSrvQueryTimeout     REG_DWORD
Range: 100 - 0xFFFFFFFF milliseconds
Default: 1500 (1.5 seconds)
Determines the time interval between successive name queries to WINS for a given name.

WinsDownTimeout     REG_DWORD    
Range: 1000 - 0xFFFFFFFF msec
Default: 15,000 (15 seconds)
Determines how long NetBT waits before trying to use WINS after it fails to contact any WINS server. This feature allows machines that are temporarily disconnected from the network, such as laptops, to proceed through boot processing without waiting for each WINS name registration to time out or query the servers individually.

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:edsont
ID: 1402689
I'll try to use you first suggestion because modifying so many registry entries can be pretty dangerous.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1402690
Good luck.  Please share the results.
0
 

Expert Comment

by:dipenpatel79
ID: 20242690
I don't prefer registry update too. Please provide Visual C++ code for getHostByName using WSAAsyncGetHostByName to support timeout? Or Please provide code for solution described above "Another sulotion is installing a blocking hook before calling gethostbyname(),".
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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