What is the socket declaration for, in Ruby on Rails database.yml?

后端 未结 4 934
耶瑟儿~
耶瑟儿~ 2020-12-31 09:38

What\'s the use of socket declaration in config/database.yml ?

Example code:

staging:
  adapter: mysql
  encoding: utf8
  database: (database)
  pool         


        
4条回答
  •  忘掉有多难
    2020-12-31 10:11

    When two programs want to talk to each other over the network, one program might open up a TCP connection (a "socket") with the other one. The first program needs to know the IP address of the second computer and the port on which the program is listening.

    On Linux, when two programs on the same computer want to talk to each other, they can still open up a TCP connection. But they can also open up a connection via a "socket file". Linux makes the socket file API rather similar to the TCP API, so it's not a big deal to update a program that already communicates over the network via TCP to support communicating via socket files too. Socket files are faster than TCP, but only work when both programs are on the same computer.

提交回复
热议问题