File: client.py

package info (click to toggle)
python-network 0.4-1
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 280 kB
  • sloc: python: 681; sh: 22; makefile: 11
file content (21 lines) | stat: -rwxr-xr-x 541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python3

import fhs
import network

fhs.option('port', 'port to connect to', default = '8888')
config = fhs.init(help = 'testing program for network module', version = '0.1', contact = 'Bas Wijnen <wijnen@debian.org>')

def readline(line):
	print('Client received line:', line)
	client.send(b'quit\n')

def disconnected(remote, data):
	print('Server disconnected from client')
	network.endloop()

client = network.Socket(config['port'], tls = False)
client.disconnect_cb(disconnected)
client.readlines(readline)

network.fgloop()