Skip to content

Instantly share code, notes, and snippets.

@IbroCalculus
Created February 18, 2019 00:14
Show Gist options
  • Save IbroCalculus/a85b5ff382231b97131b467f8181e7b4 to your computer and use it in GitHub Desktop.
Save IbroCalculus/a85b5ff382231b97131b467f8181e7b4 to your computer and use it in GitHub Desktop.
Server code for python remote access of another machine on which the server part of this code has been installed
import socket
s = socket.socket()
host = socket.gethostname()
port = 9009
s.bind((host,port))
print('This host/server ID is: ', host)
print('\n',host,'has been binded to',port)
print('\nServer is listening for incoming connections')
s.listen(1)
conn, addr = s.accept()
print(addr,'has successfully connected to Server')
while True:
sendCommand = input('Server >>> ')
if sendCommand == 'Get_Current_working_Directory':
conn.send(sendCommand.encode())
receivedCommand = conn.recv(1024)
receivedCommand = receivedCommand.decode()
print('\nFrom Client >>> ',receivedCommand)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment