Added broadcast to socket, bind port for local

Also added recv function in mainloop