1

I've written a little Haskell network example, but i don't know, which port i should use.

i couldn't find a example port number in the IETF papers i found or in Wikipedia's list of port numbers, but maybe there is a common port number in the programming community.

vek
  • 1,523
  • 10
  • 18

3 Answers3

0

Ports that are beyond 1024 and under 65535 and not have been used by you computer are all OK, just choose what you like. Usually some net frameworks use 8000 or 8888.

zhangyangyu
  • 8,520
  • 2
  • 33
  • 43
0

Unless you really need a static fixed port, you are better off letting the OS pick an available random port for you, and then you can display/publish the actual port chosen so you can let your clients know which port to connect to.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

Valid numbers for ports (regardless of the programming language) are: 0 to 2^16-1 = 0 to 65535
That is because a port number is 16 bit length.

However ports are divided into:
Well-known ports: 0 to 1023 (used for system services e.g. HTTP, FTP, SSH, DHCP ...)
Registered/user ports: 1024 to 49151 (you can use it for your server, but be careful some famous applications: like Microsoft SQL Server database management system (MSSQL) server or Apache Derby Network Server are already taking from this range i.e. it is not recommended to assign the port of MSSQL to your server otherwise if MSSQL is running then your server most probably will not run because of port conflict )
Dynamic/private ports: 49152 to 65535. (not used for the servers rather the clients e.g. in NATing service)

In programming you can use any numbers 0 to 65535 for your server, however you should stick to the ranges mentioned above, otherwise some system services or some applications will not run because of port conflict.
Check the list of most ports here: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Mosab Shaheen
  • 1,114
  • 10
  • 25