Socket has many meanings. When using API, sockets are usually regarded as the abstraction of the operating system. At this point, sockets are very similar to file descriptors and are part of the application programming interface API. The socket is generated by the application and indicates whether it will be used by the client or the server. When an application process creates a socket, it should indicate the port number used by the socket.
Port is the code name of application layer service, which is used to mark the process of application layer. The port is 16-bit integer. Port numbers used by various servers are reserved so that customers can find the server. For example, the port number used by the World Wide Web server is 80.
When sending data, the data of the application layer is passed down to the transport layer through the port. When receiving data, the data in the transport layer is transmitted to the application program in the application layer through the appropriate port.
Thank you for reading my answer.