Your [questions][1] as well as other [questions][2] reveal a misconception what blocked/non-blocked or closed/open ports are.

If you want to provide a service in a network you need a process usually connected to a network socket and related addresses consisting of the local address (i.e. IP-address) and (for TCP and UDP) a port number.

So serving a website requires a process (e.g. httpd or in your example python), a socket and a related address and port (and some content). The standard port of a web server is 80.  

As soon as you start a simple web server with `sudo python -m SimpleHTTPServer 80` (port numbers less than 1024 have to be run as root) the port will be opened and you can access this from another host or locally.

To get open ports of a host you can install and launch [nmap][3]. The command to get all open TCP ports of an IP is:

    nmap IP

or all open TCP and (most) UDP ports

    sudo nmap -sT -sU IP

On a vanilla macOS Client system and after starting Python's simple HTTP server (which is attached to all internal interfaces: localhost, en0 with the IP 192.168.0.2 here,...) you will get following nmap results launched on the local host and **no** local firewall enabled:

    nmap 127.0.0.1   
    Starting Nmap 7.31 ( https://nmap.org ) at 2017-01-22 22:12 CET
    Nmap scan report for 127.0.0.1
    Host is up (0.0043s latency).
    Not shown: 750 closed ports, 249 filtered ports
    PORT   STATE SERVICE
    80/tcp open  http

    nmap 192.168.0.2    
    Starting Nmap 7.31 ( https://nmap.org ) at 2017-01-22 22:12 CET
    Nmap scan report for 192.168.0.2
    Host is up (0.0043s latency).
    Not shown: 750 closed ports, 249 filtered ports
    PORT   STATE SERVICE
    80/tcp open  http

After stopping the Python server you won't get any open TCP port though no firewall is enabled! Your Mac just doesn't provide any services. Vanilla macOS client hosts usually don't have any open TCP ports. You can enable some though: e.g. ssh on port 22. BTW if you detect an open port 631 then it's printer sharing (which is a service again). 

    sudo nmap -sT -sU 127.0.0.1
    Starting Nmap 7.31 ( https://nmap.org ) at 2017-01-22 22:18 CET
    Nmap scan report for localhost (127.0.0.1)
    Host is up (0.00019s latency).
    Not shown: 1891 closed ports, 78 open|filtered ports, 29 filtered ports
    PORT    STATE SERVICE
    80/tcp  open  http
    123/udp open  ntp

    sudo nmap -sT -sU 192.168.0.2
    Starting Nmap 7.31 ( https://nmap.org ) at 2017-01-22 22:19 CET
    Nmap scan report for 192.168.0.2
    Host is up (0.00019s latency).
    Not shown: 1811 closed ports, 186 open|filtered ports
    PORT     STATE SERVICE
    80/tcp   open  http
    123/udp  open  ntp
    5353/udp open  zeroconf

A closed port means: no service is running on portX. The other meanings of the different port states are explained here: [Port Scanning Basics][4]. 

A port scan of 192.168.0.2 from another host in the same network will yield the same results.

---

In a SOHO network you usually find the following devices:


    host1--------(switch-router(firewall))--------WAN/Internet
                   |
    host2-----------

Each of the hosts may have an (enabled) firewall or packet filter, the router usually always has an enabled firewall.

After starting your Python web server on host1 you will be able to detect the open port 80 scanning from host1 and host2. You **can't** detect **any** open port on the local hosts from the WAN because the LAN is protected by the router's  firewall (and not reachable due to its private nature).

After enabling a firewall1 on host1 (with the pf example rule *block drop any to any port 80*) you won't be able to detect or access the still **open** port 80 scanning with host2 because the firewall1 **blocks** access.

Now relaunch the Python server with port 8080. Now you will detect no open port 80 but an open port 8080 from both hosts. The firewall1 only blocks port 80 and access is possible from host2. If you additionally add a port-forwarding rule (= punching a hole in the router's firewall) *forward incoming packets to port 10080 to host1 port 8080* you will get the following results:

- scanning from the WAN you will get an open port 10080 (though no open port 10080 exists on the LAN's hosts)
- scanning from the LAN you will still detect an open port 8080 on host1

---

Get the state of a hosts` firewalls:

- pf: enter `sudo pfctl -s all | grep Status`. If you get "enabled" additionally enter `sudo pfctl -vnf /etc/pf.conf` to get all anchors and rules. If you don't see any blocking rule (the default OS X pf state) nothing is blocked.
- Murus: check the traffic light in the upper right corner
- Application Firewall: on/off in System Preferences > Security > Firewall
- Little Snitch: check any outgoing blocking rule
- Other Firewalls (like NetBarrier) usually check some on/off switches

---

iMessages doesn't require any **open** service port on your Mac. Since iMessages tries to establish a keep-alive connection to some Apple servers it would be blocked by a host's or the router's firewall (or a dedicated firewall) though, if either of them blocks **outgoing** traffic to these servers on the ports 80, 443, and 5223 - and/or the **incoming** Apple Push Notification Service (IIRC this only possible with deep packet inspection & mitm).

In comparison, starting the Messages **service** in **macOS Server** will open the ports 80, 443 and 5222 on the server host.

---

Reading all your similar questions concerning iMessages I don't think your problem is related to your host's macOS but either to some kind of installed Endpoint Protection or a very restrictive firewall in the network. Or your IP/device/account is blocked by Apple!


  [1]: https://apple.stackexchange.com/users/219378/typosruinjokes?tab=questions
  [2]: https://apple.stackexchange.com/questions/223471/how-to-open-specific-port-in-ei-captain
  [3]: https://nmap.org/download.html#macosx
  [4]: https://nmap.org/book/man-port-scanning-basics.html