forked from Jatin1o1/ABB-Robot-with-python-socket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_socket_script.py
More file actions
45 lines (31 loc) · 866 Bytes
/
python_socket_script.py
File metadata and controls
45 lines (31 loc) · 866 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
38
39
40
41
42
43
44
45
# Import socket module
import socket
# Create a socket object
s = socket.socket()
# Define the port on which you want to connect
port = 1025
# connect to the server on local computer
#s.connect(('127.0.0.1', port))
print("hi")
try:
s.connect(('192.168.98.94', port))
except:
while True:
if (s.connect(('192.168.98.94', port)) != True ):
break
print("trying to connect")
# receive data from the server
data = s.recv(4096)
if len(data)>0:
res=str(data)
print(res[2:len(res)-1])
def values():
for i in range(0,6):
inp=input("enter value")
s.send(bytes(inp, 'utf-8'))
data = s.recv(4096)
if len(data)>0:
res=str(data)
print(res[2:len(res)-1])
values()
#s.close()