mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Added and updated documentation
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
# Python rough implementation of a C# TCP client
|
||||
import socket
|
||||
|
||||
|
||||
class TcpClient:
|
||||
|
||||
def __init__(self):
|
||||
self.connected = False
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
def connect(self, ip, port):
|
||||
"""Connects to the specified IP and port number"""
|
||||
self.socket.connect((ip, port))
|
||||
|
||||
def close(self):
|
||||
"""Closes the connection"""
|
||||
self.socket.close()
|
||||
|
||||
def write(self, data):
|
||||
"""Writes (sends) the specified bytes to the connected peer"""
|
||||
self.socket.send(data)
|
||||
|
||||
def read(self, buffer_size):
|
||||
"""Reads (receives) the specified bytes from the connected peer"""
|
||||
self.socket.recv(buffer_size)
|
||||
|
Reference in New Issue
Block a user