Use Python For Socket Programming To Connect Two or More PCs To Share A Text File. | I'M FROSTY
Make some Money!

What's Hot

recentposts

Use Python For Socket Programming To Connect Two or More PCs To Share A Text File.

========= To server.py File =======
 #!/usr/bin/python           # This is server.py 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()
============ To File.txt File ============
HELLO.....
============ OUTPUT ============
[[email protected] ~]$ python server.py
Got connection from ('192.168.2.233', 40628).
Use Python For Socket Programming To Connect Two or More PCs To Share A Text File. Reviewed by Hardik Pandya on 1:09:00 PM Rating: 5

No comments:

All Rights Reserved by I'M FROSTY © 2014 - 2016
*The Content Is Copyrighted To & May Not Be Copied / Republished.

Contact Form

Name

Email *

Message *

Powered by Blogger.