![]() |
|
Pythonosc- turn on server for 10 minutes and close in a loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: Pythonosc- turn on server for 10 minutes and close in a loop (/thread-9079.html) |
Pythonosc- turn on server for 10 minutes and close in a loop - SwethaSharma - Mar-20-2018 Hi Everyone, I am using python osc for connecting to a sensor, I want to connect to the sensor for 10 minutes receive the messages and close the server. The following is the code I have for doing job: from pythonosc import udp_client
from pythonosc import osc_message_builder
from pythonosc import dispatcher
import socket, threading, time
from pythonosc import osc_server
import time
tstart=time.time();
# Change this to the NGIMU IP address
send_address = '192.100.1.1', 9000
client =udp_client.SimpleUDPClient('192.100.1.1', 9000)
# msg=osc_message_builder.OscMessageBuilder()
# msg=msg.build()
print(str(socket.gethostbyname(socket.gethostname())))
#receive_address='192.100.16.2', 8000
dispatcher = dispatcher.Dispatcher()
server = osc_server.ThreadingOSCUDPServer(('192.100.16.2', 8001),dispatcher)
#server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
print("Serving on {}".format(server.server_address))
server.server_activate()
#server.server_close()
tnow= time.time();
tdiff= tnow-tstart
while(tdiff*1000<10):
tnow= time.time();
tdiff= tnow-tstart;
print(tdiff)
if(tdiff*1000>10):
server.server_close()I am getting the following error:How do I solve this error?-swetha |