Skip to content

Instantly share code, notes, and snippets.

@pratikpc
Last active October 31, 2019 00:42
Show Gist options
  • Select an option

  • Save pratikpc/34d3a48191520efb122d9e6549ed0fae to your computer and use it in GitHub Desktop.

Select an option

Save pratikpc/34d3a48191520efb122d9e6549ed0fae to your computer and use it in GitHub Desktop.

Revisions

  1. pratikpc revised this gist Oct 31, 2019. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. pratikpc created this gist Oct 31, 2019.
    14 changes: 14 additions & 0 deletions Client.py
    Original 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")
    19 changes: 19 additions & 0 deletions Server.py
    Original 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')