AmmosSource
guix
Last change
on this file since 2d2c629 was f3421e6, checked in by recknagel <recknagel@…>, 3 years ago |
updated sample_scripts
|
-
Property mode
set to
100644
|
File size:
633 bytes
|
Rev | Line | |
---|
[1e781ba] | 1 | import sys
|
---|
| 2 | import os
|
---|
[f3421e6] | 3 | sys.path.append('../src/')
|
---|
[1e781ba] | 4 | import socket
|
---|
| 5 |
|
---|
| 6 | try:
|
---|
| 7 | file_path = sys.argv[1]
|
---|
| 8 | except IndexError:
|
---|
| 9 | print("Please provide a file path as argument")
|
---|
| 10 | sys.exit(1)
|
---|
| 11 | except FileNotFoundError:
|
---|
| 12 | print("File not found")
|
---|
| 13 | sys.exit(1)
|
---|
| 14 |
|
---|
| 15 | file = open(file_path, 'rb')
|
---|
| 16 | total_bytes = file.read()
|
---|
| 17 | print('File read')
|
---|
| 18 |
|
---|
| 19 | print('Connecting to socket')
|
---|
| 20 | out_socket = socket.socket()
|
---|
| 21 | out_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
---|
| 22 | out_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
---|
| 23 | out_socket.connect(('127.0.0.1', 12345))
|
---|
| 24 | print('Connected')
|
---|
| 25 | print('Sending Bytes')
|
---|
| 26 | out_socket.sendall(total_bytes)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.