-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinterface.py
More file actions
37 lines (30 loc) · 856 Bytes
/
interface.py
File metadata and controls
37 lines (30 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Interface ##
## v 0.92 ##
import tcp
## Will return False if there is an error
def inter(remote_ip, port, data):
rep = 0
if data != "":
s = tcp.connect(remote_ip, port)
if s != False:
#Send data
if not tcp.send(data, s):
return False
#Receive data
rep = tcp.receive(s)
if rep == False:
print("error disconnected")
return False
else:
s.close()
return rep
else:
print("An error has occured")
return False
else:
return False
if __name__ == "__main__":
ip = input("Enter ip to connect to: ")
port = 5050
info = inter(ip, port,data=input("Enter Data: "))
print(info)