473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Socket timeout in IronPython

14
Hi,
I hope it's ok for me to place an IronPython question in this forum(?).

I am running IronPython 1.1.2 and Python 2.5.
OS is Windows XP SP3.

Currently I'm developing a lightweight test framework. In short, there are two scripts that control one hardware device each. The hardware devices are communicating wirelessly. I am using IronPython because I am then able to use some needed .NET libraries seamlessly.

One functionality I need in the scripts is a way of synchronizing them with each other. The scripts are running in separate threads, so I need interprocess communication. I also need the synchronization to be able to timeout, to avoid the script from hanging indefinitely.

I have found that sockets would fit my needs well. One script binds and listens to a socket, and the other script connects to the same socket, allowing them to exchange messages.

Now, my problem is that I am not able to make the timeout of the socket to work in IronPython. When I test the same in Python it works like a charm. Here is the isolated code for demonstrating the problem:

Expand|Select|Wrap|Line Numbers
  1. from socket import *
  2.  s = socket(AF_INET, SOCK_STREAM)
  3.  s.bind(('', 8888))
  4.  s.listen(5)
  5.  s.settimeout(2)
  6.  client, addr = s.accept()
The code snippet will timeout when run in Python, but not in IronPython.

Is the implementation of socket in IronPython lacking the ability of timeout?

(Suggestions to other approaches to my problem would also be greatly appreciated.)
Dec 7 '08 #1
3 2954
bvdet
2,851 Expert Mod 2GB
oberon,

It's OK to post IronPython questions here. Unfortunately, I don't know IronPython. Your explanation of the problem is excellent. Try moving s.settimeout(2) before s.listen(5). Thanks for posting.
Dec 7 '08 #2
oberon
14
Hi,
moving s.settimeout(2) before s.listen(5) doesn't seem to make any difference, neither in IronPython or Python.
Dec 7 '08 #3
bvdet
2,851 Expert Mod 2GB
It was a shot in the dark. Documentation suggests setting the timeout as soon as a socket is created.
Dec 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
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:
5
by: Russell Warren | last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it a cross-process/system setting or does it stay local in the application in which it is called? I've been testing this and...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
1
by: jnair | last post by:
When using socket.socket.settimeout we normally only guard against "socket.timeout" exception.Now the implementation of "settimeout" in "Python-2.4.3/Modules/socketmodule.c" sets the socket fd to...
2
by: Robin Becker | last post by:
While messing about with some deliberate socket timeout code I got an unexpected timeout after 20 seconds when my code was doing socket.setdefaulttimeout(120). Closer inspection revealed that...
2
by: carl.rosenberger | last post by:
Hi, I am trying to get the following behaviour for my Socket connection: (1) Attempt a blocked read for a defined amount of time. (2) If a timeout occurs, because no data has been sent to the...
2
by: Heikki Toivonen | last post by:
M2Crypto has some old code that gets and sets socket timeouts in http://svn.osafoundation.org/m2crypto/trunk/M2Crypto/SSL/Connection.py, for example: def get_socket_read_timeout(self): return...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.