Hello,
I have build a client/server application with the socket module. The
server mades UDP broadcasting and the client only reads UDP broadcast
messages. All work fine.
Now I want to use for the same thing the socketserver module, it's ok
for the client, but I don't succeed in making work the server :-((
Here is the client (which works)
import sys
import SocketServer
host='192.168.2 0.73'
PORT=10000
class BroadcastAcquis ition(SocketSer ver.UDPServer,
SocketServer.Th readingMixIn):
def __init__(self, address, handler):
self.allow_reus e_address = 1
SocketServer.UD PServer.__init_ _(self, address, handler)
class Handler(SocketS erver.DatagramR equestHandler):
def handle(self):
print self.packet
s = BroadcastAcquis ition(('', PORT), Handler)
s.serve_forever ()
And the server (doesn't work)
import sys
import time
import SocketServer
GROUP = '192.168.20.255 '
HOST='192.168.2 0.73'
PORT=10000
class Broadcast(Socke tServer.UDPServ er, SocketServer.Th readingMixIn):
def __init__(self, address, handler):
self.allow_reus e_address = 1
SocketServer.UD PServer.__init_ _(self, address, handler)
class Handler(SocketS erver.DatagramR equestHandler):
def handle(self):
contenu=time.ct ime(time.time() )
self.send(conte nu)
print "Message envoye"
time.sleep(1)
s = Broadcast(('', PORT), Handler)
s.serve_forever ()
I know I have to set the SO_BROADCAST attribute and the network mask for
the broadcast but I don't know how and where in the programm.
Olivier
PS: Excuse for my poor english !!
I have build a client/server application with the socket module. The
server mades UDP broadcasting and the client only reads UDP broadcast
messages. All work fine.
Now I want to use for the same thing the socketserver module, it's ok
for the client, but I don't succeed in making work the server :-((
Here is the client (which works)
import sys
import SocketServer
host='192.168.2 0.73'
PORT=10000
class BroadcastAcquis ition(SocketSer ver.UDPServer,
SocketServer.Th readingMixIn):
def __init__(self, address, handler):
self.allow_reus e_address = 1
SocketServer.UD PServer.__init_ _(self, address, handler)
class Handler(SocketS erver.DatagramR equestHandler):
def handle(self):
print self.packet
s = BroadcastAcquis ition(('', PORT), Handler)
s.serve_forever ()
And the server (doesn't work)
import sys
import time
import SocketServer
GROUP = '192.168.20.255 '
HOST='192.168.2 0.73'
PORT=10000
class Broadcast(Socke tServer.UDPServ er, SocketServer.Th readingMixIn):
def __init__(self, address, handler):
self.allow_reus e_address = 1
SocketServer.UD PServer.__init_ _(self, address, handler)
class Handler(SocketS erver.DatagramR equestHandler):
def handle(self):
contenu=time.ct ime(time.time() )
self.send(conte nu)
print "Message envoye"
time.sleep(1)
s = Broadcast(('', PORT), Handler)
s.serve_forever ()
I know I have to set the SO_BROADCAST attribute and the network mask for
the broadcast but I don't know how and where in the programm.
Olivier
PS: Excuse for my poor english !!
Comment