Skip to main content

TCP framework in flavor of Netty

Project description

py-netty :rocket:

An epoll-based TCP networking library for Python 3.7+.

APIs are similar to the Netty framework.

Installation

python -m pip install py-netty

Getting Started

Start an echo server:

from py_netty import ServerBootstrap
ServerBootstrap().bind(address='0.0.0.0', port=8080)

As TCP client:

from py_netty import Bootstrap
from py_netty.handler import NoOpChannelHandler


class HttpHandler(NoOpChannelHandler):

    def channel_read(self, ctx, buffer):
        print(buffer.decode('utf-8'))

b = Bootstrap(handler=HttpHandler())
channel = b.connect(remote_address, remote_port).sync()
request = f'GET / HTTP/1.1\r\nHost: {remote_address}\r\n\r\n'
channel.write(request.encode('utf-8'))

Performance Test

Example

Example

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

py-netty-0.0.3.tar.gz (10.5 kB view hashes)

Uploaded Source

Built Distribution

py_netty-0.0.3-py3-none-any.whl (11.4 kB view hashes)

Uploaded Python 3

Supported by

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