sockets question

M

Mohammed Smadi

hi;

i have the following piece of code:
=============
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(("",port))
s.sendto(data,(MY_GW,port))
data = s.recvfrom(1024)
============

data contains some instructions which i am sending to MY_GW. If the
reply arrives from the MY_GW quickly then things fine, otherwise the
program is going to freeze waiting for the reply. I want to do the
following:

1- Be able to impose a timeout after which i want to stop executing
the s.recvfrom statement.

rgds;
m.smadi
 
A

Artificial Life

hi;

i have the following piece of code:
=============
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(("",port))
s.sendto(data,(MY_GW,port))
data = s.recvfrom(1024)
============

data contains some instructions which i am sending to MY_GW. If the
reply arrives from the MY_GW quickly then things fine, otherwise the
program is going to freeze waiting for the reply. I want to do the
following:

1- Be able to impose a timeout after which i want to stop executing
the s.recvfrom statement.

rgds;
m.smadi


That happens because those functions 'block.' Search for Non-blocking
sockets, and the 'select' module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top