# ------------------------------------------------------------
# Copyright © 2026/2027 Dr. Mohammad Alja'afreh. All rights reserved.
# PSUT IoT Engineering Learning Platform
# ------------------------------------------------------------
# ---- Runs on sensor node room-101  (IP 192.168.1.31)
import socket
 
# TCP/IPv4 socket for the node (client side).
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as c:
    c.connect(('127.0.0.1', 5000))    # gateway IP + port (handshake)
    print('My end   :', c.getsockname())  # port chosen by the OS
    print('Other end:', c.getpeername())  # the gateway's IP and port
    c.sendall(b'room-101,24.5')          # 13 bytes of data
    print('Reply:', c.recv(1024).decode())
