So I have this python server which just returns the uppercase sentence which came as a input:
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('192.168.1.2', serverPort))
print "The server is ready to receive on port: {}".format(serverPort)
while 1:
message, clientAddress = serverSocket.recvfrom(2048)
print clientAddress, message
modifiedMessage = message.upper()
serverSocket.sendto(modifiedMessage, clientAddress)
From this client:
from socket import *
serverName = "192.168.1.3"
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_DGRAM)
message = raw_input("Input lowercase sentence:")
clientSocket.sendto(message,(serverName, serverPort))
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
print modifiedMessage
clientSocket.close()
Everything works as expected on localhost
but when I execute server.py
on one machine and run client.py
on another machine the client is unable to contact server.py
.
Furthermore I can't even connect to server.py
via telnet
on the same machine where server.py
is running)
Here's the traceback:
Connecting To 192.168.1.2...Could not open connection to the host, on port 12000: Connect failed
Now I sniffed some packets using Wireshark and surprisingly, the protocol against this packet was LLC
instead of UDP
and the data field was:
Data: 74:5f:32:20:61:6e:64:72:6f:69:64
[Length: 11]
I apologize if the difference is trivial, but I have just started socket programming and it's bugging me.
server.py
from other clients on LAN