========= To server.py File =======
#!/usr/bin/python # This is server.py file============ To File.txt File ============
import socket # Import socket module
import sys
s = socket.socket() # Create a socket object
host = '192.168.2.232'
port = 4444 # Reserve a port for your service.
s.bind((host, port)) # Bind to the port
s.listen(5) #Now wait for client connection.
fileToSend = open("ToSend.txt","r")
content = fileToSend.read()
while True:
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.sendall(content)
c.close() # Close the connection
fileToSend.close()
HELLO.....============ OUTPUT ============
[hnpandya@localhost ~]$ python server.py
Got connection from ('192.168.2.233', 40628).