473,796 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

timeout in socket.gethostb yname()?

I've tried using

socket.setdefau lttimeout(timeo ut)

to set the default timeout to 'timeout' for all sockets. The part
that's not clear to me, is that if this will affect
socket.gethostb yname(). In my observation the timeout setting did not
affect the DNS lookup.

It might be my misunderstandin g of the semantics here: would
setdefaulttimeo ut() only applies to any socket object newly created?
So gethostbyname() doesn't create a new socket (explicitly at least)
so timeout doesn't apply there? What should I do to get the intended
behavior?

Thanks a bunch!
Jul 18 '05 #1
1 7148
Ok so for now I use a separate thread to run gethostbyname, and stop
waiting for the result if time is running up. But would be interested
in knowing a simpler way doing this. Thanks!

fo************* @yahoo.com.tw (Fortepianissim o) wrote in message news:<ef******* *************** ****@posting.go ogle.com>...
I've tried using

socket.setdefau lttimeout(timeo ut)

to set the default timeout to 'timeout' for all sockets. The part
that's not clear to me, is that if this will affect
socket.gethostb yname(). In my observation the timeout setting did not
affect the DNS lookup.

It might be my misunderstandin g of the semantics here: would
setdefaulttimeo ut() only applies to any socket object newly created?
So gethostbyname() doesn't create a new socket (explicitly at least)
so timeout doesn't apply there? What should I do to get the intended
behavior?

Thanks a bunch!

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
52231
by: Achim Domma | last post by:
Hi, I'm using Python 2.3s timeout sockets and have code like this to read a page from web: request = ... self.page = urllib2.urlopen(request) and later:
0
6037
by: Eric Brunel | last post by:
Hi all, I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I have one problem that I can't figure out: when I wanted to get "the" IP address of the current host with Python 2.1, I did: Python 2.1.1 (#12, Apr 10 2002, 17:52:08) on linux2 Type "copyright", "credits" or "license" for more information. >>> import socket
0
1950
by: Jacob Lee | last post by:
I'm getting a rather bizarre error while using the socket module. If I start out disconnected from the net and then connect while the program or interpreter session is open, I do not always gain the ability to resolve or connect to hosts by name. Here is the problematic scenario: <Unplug network cable> >>> from socket import * >>> gethostbyname('google.com') # Fails as expected Traceback (most recent call last):
1
6544
by: Gareth Crispin | last post by:
Good afternoon, I'm rewriting a piece of perl code in C++ that simply checks availability of a port. It's fairly simple, and returns UP, DOWN or NODNS. This works great, and is just what I need. Except when network issues, or firewalls drop packets silently. It'll sit and hang around forever, which grinds the scripts dependant upon it to a halt.
10
1520
by: balzano_1 | last post by:
Hi, im trying to send text from one pc to anther using C socket programming, i used send() to send the text, the text i used to send is a result of a function, the problem is the other side recieves gibbarish, here are server.c and client.c ------------ server.c ------------ #include <stdio.h> #include <stdlib.h> #include <unistd.h>
2
702
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no more data to expect). Sometimes, Socket.Available returns 0 but the other end of the connection did not close it ! 2) This class will be used by many other classes so I have to use the
9
1826
by: KL | last post by:
Hey...I am working on a project for school. I preface this so everyone understands that I don't want the full answer, rather a nudge in the correct direction. The following code section is supposed parse in a url from the command line. For some reason, I am not parsing the command line properly. Can someone help nudge me towards the correct way to do this? int main(int argc, char *argv) {
2
13756
by: flamesrock | last post by:
Hi, Basically, I'm trying to send a multipart form to a server using some code from aspn.. here it is: MultipartPostHandler: http://pastie.caboo.se/29833 import MultipartPostHandler, urllib2, cookielib cookies = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),
8
14241
by: half.italian | last post by:
Hi all, I'm having trouble with the socket module resolving a hostname. It seems like this is a system level problem, but I'm not even sure where to start. I can ping the smtp server by name and IP, but when smtp.SMTP("theHost") tries to get the hostname, it keeps giving me the following error: File "bin/program.py", line 123, in notify smtp = smtplib.SMTP("theHost")
0
9679
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.