Skip to content

sefadegirmenci/CPP-Socket-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CPP-Socket-Library

Description

The easiest way of creating TCP sockets and implementing message transfers. Through this library you can create your own servers and clients. Bear in mind that this project is not product-safe. It is only for experimenting socket programming, and having a good understanding of the underlying structure of the networks.

Usage

  1. Download the repo.
  2. Copy the src folder to your workspace
  3. Add #include "src/connection.h" to the file you want to use the sockets.
  4. Use the methods described below

One of the aims of this project is to make it a library, however, it is not at that stage yet.

Methods

connect_socket(char *hostname, int port): Returns a socket file descriptor that is connected to the hostname on the given port.

accept_connection(int sockfd): Accepts a connection on the specified socket.

listen_socket(int port): Returns a socket file descriptor that is listening on the specified port.

recv_msg(int sockfd, std::string* message): Receives a message from the socket, assigns it to the message parameter for further processing.

Contribution

You are more than welcomed to contribute to this project. You can select one of the issues from the TODO list. Or you can come up with your own idea.

TO-DO:

  • Turn the package into a library
  • Send message over the tcp socket
  • Receive message over the tcp socket
  • Protobuf support
  • Async IO - nonblocking accept connection and message transfer
  • Concurrency support
  • Receive message until the read_byte is less than or equal to 0.

About

TCP socket library for network(socket) programming in C++

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages