Skip to content

[Enhancement] Refactor Socket Logic to Separate Source File #1

@Wizardous

Description

@Wizardous

[Enhancement] Refactor Socket Logic to Separate Source File

Description

The current implementation of the project includes server.cpp and client.cpp source files, containing all the logic for opening and connecting to sockets using the TCP protocol and then transferring files. The objective of this enhancement is to move the socket logic to a separate source file (socket.cpp), which will only handle the responsibility of opening and managing sockets. This refactored socket logic will be used by both the client and server side code to open their corresponding socket instances. Once the sockets are initiated and connected, the client and server can continue with their respective file transfer logic.

Motivation

1. Separation of Concerns: By moving the socket logic to a separate source file, we can achieve a clearer separation of concerns, making the codebase more modular and easier to maintain.

2. Reusability: This refactored socket logic can be reused for other projects, such as video streaming using the UDP protocol or implementing an HTTP server, extending the flexibility and scalability of the codebase.

3. Scalability and Robustness: By encapsulating the socket operations, the project can be further developed and scaled with additional functionalities while maintaining robustness and code clarity.

Steps to Implement

  1. Create a new source file (socket.cpp) and header file (socket.h).
  2. Move all socket-related logic from server.cpp and client.cpp to socket.cpp.
  3. Modify server.cpp and client.cpp to include and use the new socket functions from socket.cpp.
  4. Ensure that both client and server can initiate, connect, and transfer files using the refactored socket logic.
  5. Test the implementation to verify that the socket operations and file transfers work as expected.

Expected Outcome:

  • A modular and maintainable codebase with a clear separation of concerns.
  • Reusable socket logic for various types of networking projects.
  • Enhanced scalability and robustness of the TCP File Transfer project.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions