NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

from socket import *
import time
import threading
import os


find = {}
ips = []
def readyconn():
s = socket()
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
host = "localhost"
port = 8888
s.bind((host,port))
s.listen(2)
ad = raw_input("ad: ")
c, ip = s.accept()
c.send(ad)
c.close()
receive()
def receive():
s = socket()
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
host = "localhost"
port = 8888
s.bind((host,port))
s.listen(2)
c, ip = s.accept()
filename = c.recv(1024)
size = c.recv(1024)
print "Receive file please wait"
file = c.recv(int(size))
print "File received"
print "Creating and writing file"
with open(filename,"w") as nfile:
nfile.write(file)
print "Transfer Completed"
c.close()



def send():
if len(find)>0:
print "Found Targetsn"
for i, name in enumerate(find):
print i,name
no = input("nSelect target: ")
target = ips[no]
print "SELECTED TARGET:",find.keys()[find.values().index(target)]
print "nFile Listn"
file_list = os.listdir(os.getcwd())
for i, fname in enumerate(file_list):
print i, fname
fno = input("nSelect File: ")
file_name = file_list[fno]
print "SELECTED FILE:", file_name
file_size = os.stat(file_list[fno]).st_size
print file_size
print file_name
s = socket()
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.connect((target,8888))
s.send(file_name)
s.send(str(file_size))
with open(file_name,"r") as file_data:
file_data.read()
print "Sending File"
s.send(file_data)
print "Transfer Completed"
s.close()

else:
print "Not Found"


def is_up(addr):
s = socket()
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s.settimeout(0.09)
try:
s.connect((addr,8888))
name = s.recv(30)
find[name] = addr
ips.append(addr)
s.close()
time.sleep(0.1)
return name
except:
s.close()
time.sleep(0.1)
return False


def scanner(start,end):
ip = gethostbyname(gethostname())
lip = ip.split(".")
lip.remove(lip[3])
nip = ".".join(lip)
for i in range(start,end):
a = is_up(nip+"."+str(i))
if a == False:
pass
else:
print nip+"."+str(i)+" is up - Device Name: "+a
if i == 255:
print "Scan Completed"
send()

def run():
t1 = threading.Thread(target=scanner, args = (1,50))
t2 = threading.Thread(target=scanner, args = (50,100))
t3 = threading.Thread(target=scanner, args = (100,150))
t4 = threading.Thread(target=scanner, args = (150,200))
t5 = threading.Thread(target=scanner, args = (200,256))
t1.start()
t2.start()
t3.start()
t4.start()
t5.start()


print "1-send, 2-receive"
a = raw_input("Choose: ")
if a == "1":
run()
elif a == "2":
readyconn()
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.