'how to send data to another laptop connected with same wifi connection by python?

Hi I try to create chat window between 2 laptops. I created 2 .py files for client and server. if I run both script in same laptop, it is working fine. if I run in different laptop, it is not working. I mentioned codes below

#server.py
    import os
    from socket import *

    addr = ("xxx.xxx.x.xxx", 13000)
    UDPSock = socket(AF_INET, SOCK_DGRAM)
    UDPSock.bind(addr)
    print ("Waiting to receive messages...")
    while True:
        (data, addr) = UDPSock.recvfrom(1024)
        print ("Received message: " , data)
        if data == "exit":
            break
    UDPSock.close()
    os._exit(0)

Save as client.py

Message Sender

import os
from socket import *

UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
    data = input("Enter message to send or type 'exit': ")
    print(data)
    UDPSock.sendto(bytes(data,'utf-8'), ("XXX.XXX.X.XXX", 13000))
    if data == "exit":
        break
UDPSock.close()
os._exit(0)

I used ip address from ipconfig/all in cmd of server laptop1

Wireless LAN adapter Wi-Fi: IPv4 Address. . . . . . . . . . . : XXX.XXX.X.XXX(Preferred)

when I run both py file in 2 laptops, it is not communicating each other. have to configure anything before running these scripts?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source