-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e94bc9
commit 5eafb75
Showing
14 changed files
with
694 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
import socket | ||
|
||
|
||
s=socket.socket() | ||
|
||
s.connect(('127.0.0.1',8000)) | ||
|
||
s = socket.socket() | ||
s.connect(("127.0.0.1", 8000)) | ||
print("connecton") | ||
|
||
while True: | ||
a=input("first number") | ||
msg=a | ||
if msg=="back": | ||
a = input("first number") | ||
msg = a | ||
if msg == "back": | ||
s.close() | ||
break | ||
s.send(msg.encode()) | ||
ms=s.recv(1024) | ||
print("Answer:"+ms.decode()) | ||
# msg=input("Bob:") | ||
# s.send(msg.encode()) | ||
|
||
|
||
|
||
|
||
|
||
ms = s.recv(1024) | ||
print("Answer:" + ms.decode()) | ||
# msg=input("Bob:") | ||
# s.send(msg.encode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
import socket | ||
import socket | ||
import logging | ||
import threading | ||
import time | ||
|
||
|
||
def thread(c): | ||
print("connection is established") | ||
while(True): | ||
while True: | ||
try: | ||
msg=c.recv(1024) | ||
msg = c.recv(1024) | ||
print(c) | ||
print(msg.decode()) | ||
f=int(msg.decode()) | ||
t=str(f*f) | ||
f = int(msg.decode()) | ||
t = str(f * f) | ||
time.sleep(2) | ||
c.send(t.encode()) | ||
except: | ||
c.close() | ||
break | ||
|
||
s=socket.socket() | ||
port=8000 | ||
s.bind(('',port)) | ||
|
||
s = socket.socket() | ||
port = 8000 | ||
s.bind(("", port)) | ||
print("server started") | ||
format = "%(asctime)s: %(message)s" | ||
while(True): | ||
logging.basicConfig(format=format, level=logging.INFO,datefmt="%H:%M:%S") | ||
while True: | ||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S") | ||
s.listen(6) | ||
c,addr=s.accept() | ||
c, addr = s.accept() | ||
x = threading.Thread(target=thread, args=(c,)) | ||
x.start() | ||
print("connection is established") | ||
|
||
|
||
|
||
|
Oops, something went wrong.