Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Version 1.0
Open the Py file to read the code and its description
Still learning how to use GitHub so bear with me
  • Loading branch information
sundayScoop authored Mar 10, 2022
0 parents commit 11cf844
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
31 changes: 31 additions & 0 deletions client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'''
EthanGo v1.0
Super simple socket program. No security. No privacy.
Do not run for prolonged periods of time.
Issues:
- Each sender must take turns sending messages
- Client will crash if server not up
- Simple terminal chat is not cool
Written by Julio Medeiros
10/03/2022
'''

import socket

version = 1.0

HOST = "127.0.0.1" #input("Server's IP adress: ") # The server's hostname or IP address
PORT = 14099 # The port used by the server

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
while True:
msg = bytes(input("Me> "), "utf-8") ## Get msg to send from user and convert into bytes
s.sendall(msg) ## Send message to server
data = s.recv(1024) ## Receive any messages sent from server
print("Them> ", data.decode("utf-8") ) ## Decode messages sent from server

print(f"Received {data!r}")
35 changes: 35 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'''
EthanGo v1.0
Super simple socket program. No security. No privacy.
Do not run for prolonged periods of time.
Issues:
- Each sender must take turns sending messages
- Client will crash if server not up
- Simple terminal chat is not cool
Written by Julio Medeiros
10/03/2022
'''

import socket

version = 1.0

HOST = "127.0.0.1" # Standard loopback interface address (localhost)
PORT = 14099 # High port to evade scans

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print(f"Connected by {addr}")
while True:
data = conn.recv(1024) ## Receive messages from client
if not data: ## If data is null, connection broken > END
break
print("Them> ", data.decode("utf-8") ) ## If data exists, decode and display
msg = bytes(input("Me> "), "utf-8") ## Collect msg to send from server in bytes
conn.sendall(msg) ## Send msg to client

0 comments on commit 11cf844

Please sign in to comment.