Creating a Socket Server
The most primitive type of networking uses sockets: gateways for communication. Applications create sockets to allow for interactions; for example, the MySQL database server creates a mysql.sock
file when it’s running; any client that needs to communicate with a database uses that socket.
A socket consists of a protocol, an IP address, and a port. The two most common protocols are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). Ruby can make use of either protocol; in this chapter I’ll demonstrate TCP, which is more common. The IP address identifies a computer. Servers available on the Internet use a meaningful IP address, whereas those on local networks have dummy ones. A socket’s port is an integer ...
Get Ruby: Visual Quickstart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.