Skip to content

Usage

Aims of the project

PhoenixSocket aims to provide a versatile and efficient socket management library for the Phoenix ecosystem. It simplifies the handling of network communication, enabling seamless integration with other Phoenix libraries. The project focuses on reliability, ease of use, and performance for both scientific and industrial applications.

Key objectives

  • Provide robust socket management for Phoenix applications.
  • Ensure compatibility with various network protocols and standards.
  • Enable easy integration with other Phoenix modules through a consistent API.
  • Offer performance suitable for high-demand scientific and industrial projects.
  • Facilitate maintenance and evolution with comprehensive documentation and unit tests.

Socket Backend

PhoenixSocket provides several backends, all implementing the same generic socket API:

Backend Description
PEmptyBackend An empty backend to start the development of a custom backend for your favorite technology.
PMockSocketGenerator A mock backend which flushes data when the socket is destroyed. Nice for small tests.
PMockSocketFileGenerator A mock backend which flushes data every time the socket is used. Useful if you want to debug a crash: since data is flushed on every use, the mock file stays usable even if the program crashes mid-way.

For this last use case, if the program crashes the mock file could be left in a broken state. It can be restored in place with phoenix_mock_restore from PhoenixMock:

phoenix_mock_restore -i your_mock_file.pmocksocket

See the Mock Socket design page for how to implement a new backend, and How to test in mock mode for a walkthrough of the mock testing workflow.