Skip to main content

A library help to build tcp server/client application

Project description

A library based on asyncore, used to build tcp server/client application communicating each other with customized messages.

Examples

Server:

import asynmsg

@asynmsg.with_message_handler_config
class ServerSession(asynmsg.SessionS):

    @asynmsg.message_handler_config('Login')
    def on_Login(self, msg_id, msg_data):
        self.send_message('LoginAck', 'login success')

class Server(asynmsg.Server):
    session_class = ServerSession

Server(('127.0.0.1', 12345))
asynmsg.run_forever()

Client:

import asynmsg

@asynmsg.with_message_handler_config
class ClientSession(asynmsg.SessionC):
    def on_opened(self):
        asynmsg.SessionC.on_opened(self)
        self.send_message('Login', 'test1')

    @asynmsg.message_handler_config('LoginAck')
    def on_LoginAck(self, msg_id, msg_data):
        pass

class Client(asynmsg.ClientBlockConnect):
    session_class = ClientSession

client = Client(('127.0.0.1', 12345))
if client.is_started():
    asynmsg.run_forever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asynmsg-0.2.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file asynmsg-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for asynmsg-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9785acd094dd433f782185923cc3d5be47acd00504833775e1ff6ae443e87306
MD5 9ff6dfe8ddd233fd51b1a0b34ca43ae0
BLAKE2b-256 c12a6985da138e5bedf341fe9ddf5552f44966d764dfd5a6526457bf5b8a4ca2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page