Ziva
Ziva

Reputation: 3501

Twisted - UDP and TCP server together

I have a python implementation of a server 'MyServer', which connects to a network over UDP and thus, inherits from DatagramProtocol. This server can connect with the network only using UDP (this cannot be changed due to the network specification). The server runs as an application in the following way:

udp_server = internet.UDPServer(port, server)
application = service.Application("MyServer")
udp_server.setServiceParent(application)

I also have the implementation of a POP3 server. However, this server is connected by the POP3 client via the TCP. I would like to allow my server to also run the POP3 server, something like:

class MyServer(DatagramProtocol):
  def __init__(self, params):
     self.POP3server = POP3Server(params) #my implementation of POP3 server

TCP and UDP are totally different protocols, but maybe there is possibility or a tricky solution to allow a TCP POP3Server run as part of a UDP Server?

Upvotes: 0

Views: 511

Answers (1)

Jean-Paul Calderone
Jean-Paul Calderone

Reputation: 48335

from twisted.application.internet import UDPServer, TCPServer

...
UDPServer(port, udp_server).setServiceParent(application)
TCPServer(port, tcp_server).setServiceParent(application)

Upvotes: 1

Related Questions