コード例 #1
0
def startClient(ip, port):
    fileName = input("Enter filename: ")

    # launch localhost client connecting to server
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(("0.0.0.0", random.randint(10000, 60000)))

    ch = ConnectionHandler(sock, 100, 0.1)

    # create connection
    streamID = random.randint(0, 2 ^ 32 - 1)
    c = ClientConnection((ip, port), ch, streamID, 100, 1, fileName)

    # client sends content to server
    ch.addConnection(c)
    ch.serve()
    print("File sent biatch!")
コード例 #2
0
ファイル: bTCP_client.py プロジェクト: kliyer-ai/bTCP
                    default=5)
parser.add_argument("-i", "--input", help="File to send", default="tmp.file")
args = parser.parse_args()

server_ip = "127.0.0.1"
server_port = 9002

sock = socket.socket(
    socket.AF_INET,
    socket.SOCK_DGRAM)  #socketWrapper.perfectSocket(("localhost",9001)) # UDP
sock.bind((server_ip, server_port))

ch = ConnectionHandler(sock, args.window, args.timeout)

# get file to send
fileName = "text.txt"  # input("Enter file name: ")

# create connection
streamID = 1111
c = ClientConnection(("127.0.0.1", 9001), ch, streamID, args.window,
                     args.timeout, fileName)

# add connection
ch.addConnection(c)

try:
    ch.serve()

except KeyboardInterrupt:
    ch.stop()