473,804 Members | 2,184 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 7150
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
52234
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
6039
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
1953
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
6545
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
1521
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
13759
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
14254
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
9712
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
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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...
0
9171
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...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4308
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
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.