A socket is one endpoint of a two-way communication link between two programs running on the network (this definition is taken from Oracle.) This isn't only about communication between programs on different devices: programs running on the same device may also communicate via a socket. Sockets are a type of Message Passing.
Each socket consists of two elements: an IP address and a port. An IP address (stands for Internet Protocol) is a structure consisting of 4 or 6 numbers separated by dots or colons (e.g., 192.0.2.1 or 2001:0db8:85a3:0000:0000:8a2e:0370:7334) that identifies a network of devices. A port is an integer between 1 to 65535 that identifies a specific device within that network.
When some program A wants to communicate with program B, it calls socket library functions. Program A passes the IP address and the port number of program B to the functions. For the communication to start, program B must call socket functions on its end, too, indicating program A's IP address and port number. The programs aren't even required to be written in the same language!