Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Console/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import socket

def get_ip_address():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
return s.getsockname()[0]

HOST = get_ip_address()
PORT = '8080'

while True:
# Press `CTRL + C` to exit client

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((HOST, int(PORT)))

message = input('\nEnter Message : ')
client_socket.send(message.encode('utf-8'))

# print(client_socket.recv(1024).decode('utf-8'))
client_socket.close()
1 change: 1 addition & 0 deletions Console/client/192.168.56.1c_client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020-06-05 11:18:55.486780 [ NEW ]!@#...i see!@#mai mast tu bta!@#shi h, cheers!@#ohh!@#what!@#ok!@#?!@#;)!@#bye!@#2020-06-05 11:21:45.091627 [ NEW ]!@#...!@#!@#ok!@#2023-05-24 21:09:36.059729 [ NEW ]!@#...hi!@#ok!@#
1 change: 1 addition & 0 deletions Console/client/192.168.56.1c_server.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020-06-05 11:18:55.486780 [ NEW ]!@#... ok!@# hi kaisi h!@# mai bhi!@# beers XD!@# i love it!@# ignore!@# na!@# !!!!@# haha!@#2020-06-05 11:21:45.091627 [ NEW ]!@#... ok!@# okkk!@# ok!@# what!@#2023-05-24 21:09:36.059729 [ NEW ]!@#... hi!@# hey!@#
Binary file added Console/client/__pycache__/client.cpython-37.pyc
Binary file not shown.
Binary file added Console/client/client.exe
Binary file not shown.
66 changes: 66 additions & 0 deletions Console/client/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import socket, datetime, os

day = str(datetime.datetime.now()) + ' [ NEW ]!@#' + '...'

def history(host):

server = host + 'c_server.txt'
client = host + 'c_client.txt'

with open(server, 'a') as s:
s.write(day)

with open(client, 'a') as c:
c.write(day)

with open(server, 'r') as s:
res = s.read()

with open(client, 'r') as c:
rec = c.read()

for s, c in zip(res.split('!@#'), rec.split('!@#')):
print(s)
print(' ' + c)

return server, client

def client_program():
host = input('\nEnter host IP : ')

# host = '192.168.56.1'
port = 5000

nick = input('\nEnter your Nickname : ')
# nick = 'vicks'

client_socket = socket.socket()
client_socket.connect((host, port))

print('\nConnected...\n')
server, client = history(host)

message, j = "hi, it's " + nick, 1

while message.lower().strip() != 'bye':

os.system('color ' + str(j))
j = (j + 1) % 7

client_socket.send((' ' + message).encode())
data = client_socket.recv(1024).decode()

with open(server, 'a') as s:
s.write(data + '!@#')

print(data)
message = input(" -> ")

with open(client, 'a') as c:
c.write(message + '!@#')

client_socket.close()

if __name__ == '__main__':
client_program()
input('\nchatting is ended...')
Binary file added Console/client/photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions Console/client/sender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import socket
import os, tqdm

SEPARATOR = "<SEPARATOR>"
BUFFER_SIZE = 1024 * 4 #4KB

def send_file(filename, host, port):
filesize = os.path.getsize(filename)
s = socket.socket()
print(f"[+] Connecting to {host}:{port}")
s.connect((host, port))
print("[+] Connected.")

s.send(f"{filename}{SEPARATOR}{filesize}".encode())
progress = tqdm.tqdm(range(filesize), f"Sending {filename}",
unit="B", unit_scale=True, unit_divisor=1024)

with open(filename, "rb") as f:
for _ in progress:
bytes_read = f.read(BUFFER_SIZE)
if not bytes_read:
break
s.sendall(bytes_read)
s.close()

if __name__ == "__main__":

hostip = input('\nEnter Host IP : ')
file = input('\nPaste file path : ')
send_file(file, hostip, 5001)
17 changes: 17 additions & 0 deletions Console/client/video_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import cv2
import socket
import pickle
import struct

cap=cv2.VideoCapture(0)
host = input('\nEnter Host IP : ')

clientsocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clientsocket.connect((host,5000))

while True:

ret,frame=cap.read()
c_data = pickle.dumps(frame)
message_size = struct.pack("L", len(c_data))
clientsocket.sendall(message_size + c_data)
105 changes: 105 additions & 0 deletions Console/console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

import os

board = {
1: ' 1',
2: ' 2',
3: ' 3',
4: ' 4',
5: ' 5',
6: ' 6',
7: ' 7',
8: ' 8',
9: ' 9'
}


def printBoard(board):
n = 16
print()
print('-' * n)
print('| ' + board[1] + ' | ' + board[2] + ' | ' + board[3] + ' |')
print('-' * n)
print('| ' + board[4] + ' | ' + board[5] + ' | ' + board[6] + ' |')
print('-' * n)
print('| ' + board[7] + ' | ' + board[8] + ' | ' + board[9] + ' |')
print('-' * n)
print()


printBoard(board)


def checkBoard(board):
# check who won

if board[1] == board[2] == board[3]:
print(board[1] + ' Won')
toreturn = True
elif board[4] == board[5] == board[6]:
print(board[4] + ' Won')
toreturn = True
elif board[7] == board[8] == board[9]:
print(board[7] + ' Won')
toreturn = True

elif board[1] == board[4] == board[7]:
print(board[1] + ' Won')
toreturn = True
elif board[2] == board[5] == board[8]:
print(board[2] + ' Won')
toreturn = True
elif board[3] == board[6] == board[9]:
print(board[3] + ' Won')
toreturn = True

elif board[1] == board[5] == board[9]:
print(board[1] + ' Won')
toreturn = True
elif board[3] == board[5] == board[7]:
print(board[3] + ' Won')
toreturn = True

else:
toreturn = False
return toreturn


ox = next = 1
mykey = []
print('Enter any number from 1 to 9')


while next:
ox %= 2
value = ['😄', '❌']
mess = f"{value[ox]}'s turn : "
key = int(input(mess))

if key not in mykey:
if key not in range(1,10):
os.system('cls')

printBoard(board)
print('Enter number within 1 and 9')
continue

mykey.append(key)
board[key] = value[ox]
ox += 1

os.system('cls')
printBoard(board)
if checkBoard(board):
break
else:
print('You tried to Over-Write, Try again...\n')
next = 0
next += 1

if set(mykey) == set(range(1, 10)):
print('Match Draw...')
break


input('\nPress `Enter` to Exit.')
27 changes: 27 additions & 0 deletions Console/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import socket

def get_ip_address():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
return s.getsockname()[0]

HOST = get_ip_address()
PORT = '8080'

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((HOST, int(PORT)))
server.listen(5)

while True:
# Press `CTRL + PAUSE/BREAK` to exit server

communication_socket, address = server.accept()
# print(f"\nConnected to {address}")

message = communication_socket.recv(1024).decode('utf-8')
print(f"\nMessage Recieved : {message}")
communication_socket.send(message.encode('utf-8'))

communication_socket.close()
# print(f"Communication with {address} ended")
1 change: 1 addition & 0 deletions Console/server/192.168.56.1s_client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020-06-05 11:19:01.410701 [ NEW ]!@#... hi, it's vicks!@# i see!@# mai mast tu bta!@# shi h, cheers!@# ohh!@# what!@# ok!@# ?!@# ;)!@#!@#2020-06-05 11:21:43.861238 [ NEW ]!@#... hi, it's vicks!@# !@# !@# ok!@#!@#2023-05-24 21:09:32.213914 [ NEW ]!@#... hi, it's vix!@# hi!@# ok!@#
1 change: 1 addition & 0 deletions Console/server/192.168.56.1s_server.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020-06-05 11:19:01.410701 [ NEW ]!@#...ok!@#hi kaisi h!@#mai bhi!@#beers XD!@#i love it!@#ignore!@#na!@#!!!!@#haha!@#bye!@#2020-06-05 11:21:43.861238 [ NEW ]!@#...ok!@#okkk!@#ok!@#what!@#2023-05-24 21:09:32.213914 [ NEW ]!@#...hi!@#hey!@#
Binary file added Console/server/__pycache__/server.cpython-37.pyc
Binary file not shown.
34 changes: 34 additions & 0 deletions Console/server/receiver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import socket
import os, tqdm

host_name = socket.gethostname()
SERVER_HOST = socket.gethostbyname(host_name)

print('\nHost IP is : ', SERVER_HOST)
print('\nWaiting for receiver...\n')

SERVER_PORT = 5001
BUFFER_SIZE = 4096 # 4KB
SEPARATOR = "<SEPARATOR>"

s = socket.socket()
s.bind((SERVER_HOST, SERVER_PORT))
s.listen(5)
client_socket, address = s.accept()

received = client_socket.recv(BUFFER_SIZE).decode()
filename, filesize = received.split(SEPARATOR)

filename = os.path.basename(filename)
filesize = int(filesize)
progress = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)

with open(filename, "wb") as f:
for _ in progress:
bytes_read = client_socket.recv(BUFFER_SIZE)
if not bytes_read:
break
f.write(bytes_read)

client_socket.close()
s.close()
Binary file added Console/server/server.exe
Binary file not shown.
67 changes: 67 additions & 0 deletions Console/server/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import socket, datetime, os

day = str(datetime.datetime.now()) + ' [ NEW ]!@#' + '...'

def history(host):

server = host + 's_server.txt'
client = host + 's_client.txt'

with open(server, 'a') as s:
s.write(day)

with open(client, 'a') as c:
c.write(day)

with open(server, 'r') as s:
res = s.read()

with open(client, 'r') as c:
rec = c.read()

for s, c in zip(res.split('!@#'), rec.split('!@#')):
print(c)
print(' ' + s)

return server, client

def server_program():
host_name = socket.gethostname()
host = socket.gethostbyname(host_name)

print('\nHost IP is : ', host)
port = 5000
print('\nWaiting for receiver...\n')

server_socket = socket.socket()
server_socket.bind((host, port))

server_socket.listen(2)
conn, address = server_socket.accept()

print("Connection from: " + str(address), end = '\n\n')
server, client = history(host)
message, j = 'hi', 5

while message.lower().strip() != 'bye':

os.system('color ' + str(j))
j = (j + 1) % 7

data = conn.recv(1024).decode()

with open(client, 'a') as c:
c.write(data + '!@#')

print(data)
message = input(' -> ')

with open(server, 'a') as s:
s.write(message + '!@#')

conn.send((' ' + message).encode())
conn.close()

if __name__ == '__main__':
server_program()
input('\nchatting is ended...')
Loading