Last active
October 31, 2019 00:42
-
-
Save pratikpc/34d3a48191520efb122d9e6549ed0fae to your computer and use it in GitHub Desktop.
Revisions
-
pratikpc revised this gist
Oct 31, 2019 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
pratikpc created this gist
Oct 31, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ def ToStr(string): return str(string)[2:-1] import socket with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client: client.connect(('localhost', 9000)) string = 'ABCBA' client.sendall(bytes(string, 'utf-8')) palindrome = ToStr(client.recv(1024)) if palindrome == 'true': print(string, "is palindrome") else: print(string, "is not palindrome") This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import socket def ToStr(string): return str(string)[2:-1] with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server: server.bind(('localhost', 9000)) server.listen() while True: conn, addr = server.accept() with conn: string = ToStr(conn.recv(1024)) reversed = string[::-1] print(string, reversed) if reversed == string: conn.send(b'true') else: conn.send(b'false')