I am trying to communicate between two computers and one is Mac and other one is Linux.
The code I have at server side:
import os
from socket import *
host = "192.168.1.47"
port = 10000
buf = 1024
address = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
UDPSock.bind(address)
print ("Waiting to receive messages...")
while True:
(data, address) = UDPSock.recvfrom(buf)
print("Received message: " + data)
if data == "exit":
break
UDPSock.close()
os._exit(0)
At client side I have:
import os
from socket import *
host = "192.168.1.47" # set to IP address of target computer
port = 10000
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
data = raw_input("Enter message to send or type 'exit': ")
UDPSock.sendto(data, addr)
if data == "exit":
break
UDPSock.close()
os._exit(0)
The server keeps waiting for the request and though I send some message typed in client side server is unable to receive it. The host address is my mac ip address and asking the other computer to connect to this ip. Could anyone help me understand where I went wrong. I referred to the other posts related to this topic but there were no appropriate solution for this. Thanks