Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
martelkr committed Feb 8, 2024
1 parent 17e08ea commit 50429e4
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ Socket::initSocket(domain, type, protocol); // creates socket
// create socket from previously created file descriptor
Socket(int);

// create socket of the given type
// create socket of the given type - NOTE: This returns a Socket class type that is not a Tcp or Udp socket class
Socket(domain, type, protocol);


```
### TCP server/client
Expand Down Expand Up @@ -92,18 +90,6 @@ SecureTcpClient(const int filedescriptor, SSL_CTX *sslctx);
SecureTcpClient(const std::string& ipAddr, const uint16_t port);
```
For a BSD-like approach, the following sequence can be followed:
```cpp
// Server
// create server socket and bind to all IP and 54321 port
TcpServer server(54321);
// wait for a client connection
TcpClient client = server.accept();
```

```cpp
// Client
Expand Down Expand Up @@ -133,20 +119,24 @@ UdpClient();
UdpClient(const std::string& ipAddr, const uint16_t port) noexcept(false)
```

For a BSD-like approach, the following sequence can be followed:
Create a SSL UDP Server for accepting SSL UDP clients.

```cpp
// Server
// Create a SSL UDP Server not bound to IP/port
SecureUdpServer(const std::string& keyFile, const std::string& certFile);

// create server socket bound to all IP and 54321 port
UdpServer server(54321);
// Create a SSL UDP Server bound to a given port and IP or default IP
SecureUdpServer(const std::string& keyFile, const std::string& certFile, const uint16_t port, const std::string& ipAddr = "0.0.0.0");
```
Create a SSL UDP client for connecting to SSL UDP servers.
```cpp
// Client
// Create a SSL UDP Client not attempting to connect to a SSL UDP Server (need to call SecureUdpClient::connect(IP, port) to connect)
SecureUdpClient(const std::string& keyFile, const std::string& certFile);
// Connect to UDP server on IP 127.0.0.1 and port 54321
UDPClient client("127.0.0.1", 54321);
// create a SSL UDP client connected to a given SSL UDP server waiting in a SecureUdpServer::accept call on the given IP and port
SecureUdpClient(const std::string& ipAddr, const uint16_t port, const std::string& keyFile, const std::string& certFile);
```

## Thread Safety
Expand Down

0 comments on commit 50429e4

Please sign in to comment.