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 Distribution

asynmsg-0.1.6.zip (11.4 kB view details)

Uploaded Source

File details

Details for the file asynmsg-0.1.6.zip.

File metadata

  • Download URL: asynmsg-0.1.6.zip
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for asynmsg-0.1.6.zip
Algorithm Hash digest
SHA256 13f8ed4ec5b653430e536b9c65045fff990ee5592d443ec043ce657fed253b64
MD5 6f1399ce10cc994394b8709adaa418ad
BLAKE2b-256 a92bd8b62609946f7c629285d3ed4185a05e1ef40afcf91aa0fba630bf2384c7

See more details on using hashes here.

Supported by

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