1
0
Fork 0

remove also python code.

main
Gökmen Görgen 1 month ago
parent 5f8240632b
commit b7a7a93d01
  1. 25
      .gitignore
  2. 0
      yank/__init__.py
  3. 39
      yank/client.py
  4. 38
      yank/server.py

25
.gitignore vendored

@ -1,26 +1 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
# Added by cargo
/target

@ -1,39 +0,0 @@
import socket
def get_constants(prefix):
"""Create a dictionary mapping socket module constants to their names."""
return dict((getattr(socket, n), n) for n in dir(socket) if n.startswith(prefix))
families = get_constants("AF_")
types = get_constants("SOCK_")
protocols = get_constants("IPPROTO_")
# create a tcp/ip socket
server_host = "localhost"
server_port = 10000
server_address = (server_host, server_port)
sock = socket.create_connection((server_host, server_port))
print(f"Family : {families[sock.family]}")
print(f"Type : {types[sock.type]}")
print(f"Protocol: {protocols[sock.proto]}")
print()
try:
# send data
message = b"This is the message. It will be repeated."
sock.sendall(message)
# look for the response
amount_received = 0
amount_expected = len(message)
while amount_received < amount_expected:
data = sock.recv(16)
amount_received += len(data)
print(f"received {data}")
finally:
sock.close()

@ -1,38 +0,0 @@
import socket
import sys
# create tcp/ip socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# bind the socket to the port
server_host = "localhost"
server_port = 10000
server_address = (server_host, server_port)
print(f"starting up on {server_host} port {server_port}", file=sys.stderr)
sock.bind(server_address)
# listen for incoming connections
sock.listen(1)
while True:
print("waiting for a connection", file=sys.stderr)
connection, client_address = sock.accept()
try:
print(f"connection from {client_address}", file=sys.stderr)
# receive the data in small chunks and retransmit it
while True:
data = connection.recv(16)
print(f"received {data}", file=sys.stderr)
if data:
print(f"sending data back to the client", file=sys.stderr)
connection.sendall(data)
else:
print(f"no more data from {client_address}")
break
finally:
# clean up the connection
connection.close()
Loading…
Cancel
Save