'''
example name：Socket communication
version：v1.0
date：2020.3
Author：01Studio
Description: Socket communication with computer network assistant
Forum: forum.01studio.org
'''

import socket
import time

#creat socket object
s=socket.socket()

addr=('192.168.1.111',10000)
s.connect(addr)

#Send test
s.send(b'Hello 01Studio!')

while True:

    text=s.recv(128) #Receive up to 128 bytes of data at a time

    #if nothing
    if text == '':
        pass

    #Receive data, print and send back
    else:
        print(text)
        s.send(text)

    time.sleep(0.1) #100ms query interval
