i do not have a very specified solution/answer...but I can tell u this..
u should first of all make sure that all of the devices are connected properly..so that we can make sure that the error is in the code..or from the computer..not from anything else...
second of all about the port thing..there are plenty of programs on the internet u could use to change your port..or u can try a virtual network set the ports n try the code..but I think about this problem..the best solution you have is to find out what is the current port of your server and set it right in the code..
i think I can write u a better code...or improve it..so I'm gonna take sometime to reply to you about the code..
hope I helped..I'm not that much of an expert but I gave u some of my best till now:D..good luck!