mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Add files via upload
Client for testing
This commit is contained in:
parent
fe25ce68b8
commit
d5922281a1
1 changed files with 25 additions and 0 deletions
25
socketclient.py
Normal file
25
socketclient.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Created on Fri Dec 11 21:53:35 2020
|
||||||
|
|
||||||
|
@author: parallels
|
||||||
|
"""
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
|
HOST, PORT = "localhost", 3000
|
||||||
|
data = " ".join(sys.argv[1:])
|
||||||
|
|
||||||
|
# Create a socket (SOCK_STREAM means a TCP socket)
|
||||||
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||||
|
# Connect to server and send data
|
||||||
|
sock.connect((HOST, PORT))
|
||||||
|
sock.sendall(bytes(data + "\n", "utf-8"))
|
||||||
|
|
||||||
|
# Receive data from the server and shut down
|
||||||
|
received = str(sock.recv(1024), "utf-8")
|
||||||
|
|
||||||
|
print("Sent: {}".format(data))
|
||||||
|
print("Received: {}".format(received))
|
Loading…
Reference in a new issue