Upload samstag_195.py
Browse files- samstag_195.py +38 -0
samstag_195.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""samStag.195
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1XOuNC4lKYJ2dwHMDTPLkmVVwyz05nIiy
|
8 |
+
"""
|
9 |
+
|
10 |
+
import socket
|
11 |
+
import time
|
12 |
+
bufferSize=1024
|
13 |
+
msgFromServer="Client Server Ready To Perform"
|
14 |
+
ServerPort=2222
|
15 |
+
ServerIP='192.168.88.41'
|
16 |
+
bytesToSend=msgFromServer.encode('utf-8')
|
17 |
+
RPIsocket=socket.socket(socket.AF_INIT,socket.SOCK_DGRAM)
|
18 |
+
RPIsocket.bind(ServerIP,ServerPort)
|
19 |
+
print('Server is Ready')
|
20 |
+
cnt=0
|
21 |
+
while True:
|
22 |
+
message,address=RPIsocket.recvfrom(bufferSize)
|
23 |
+
message=message.decode('uft-8')
|
24 |
+
print(message)
|
25 |
+
print('Client Address',address[0])
|
26 |
+
if message=='INC':
|
27 |
+
cnt=cnt+1
|
28 |
+
if message=='DEC':
|
29 |
+
cnt=cnt-1
|
30 |
+
msg=str(cnt)
|
31 |
+
msg=msg.encode('utf-8')
|
32 |
+
RPIdocket.sendto(msg,address)
|
33 |
+
message,address=RPIsocket.recvfrom(bufferSize)
|
34 |
+
print('here')
|
35 |
+
message=message.decode('utf-8')
|
36 |
+
print(messge)
|
37 |
+
print('Client Address',address[0])
|
38 |
+
RPIsocket.sendto(bytesToSend,address)
|