Skip to content

Instantly share code, notes, and snippets.

@flotwig
Forked from IbroCalculus/server.py
Last active February 18, 2019 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flotwig/c80ce32bc74536304897e2d0f8d1887a to your computer and use it in GitHub Desktop.
Save flotwig/c80ce32bc74536304897e2d0f8d1887a 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