MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
client.cpp File Reference
#include "mxnetwork/socket.hpp"
#include <cstdlib>
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 5 of file client.cpp.

5 {
6 if (argc != 3) {
7 std::cerr << "client: Invalid arguments\n"
8 << argv[0] << " <host> <port>\n";
9 return EXIT_FAILURE;
10 }
11
12 try {
13 mxnetwork::MXNetworkInit network_init;
16 if (sock.connect(argv[1], argv[2])) {
17 std::string data;
18 std::cout << "enter data: ";
19 std::getline(std::cin, data);
20 if (sock.write_all(data.c_str(), data.length()) > 0)
21 std::cout << "Sent " << data.length() << " bytes.\n";
22 } else {
23 std::cout << "client: Error connecting..\n";
24 }
25 } catch (const mxnetwork::Exception &e) {
26 std::cerr << "client: " << e.text() << "\n";
27 return EXIT_FAILURE;
28 }
29 return EXIT_SUCCESS;
30}
Lightweight exception wrapper for MXNetwork failures.
Definition exception.hpp:11
std::string text() const
Return the stored error text.
Definition exception.cpp:5
C++ wrapper around the MXNetwork socket API.
Definition socket.hpp:57
void mx_socket_ignore_pipe_signal()
Ignore SIGPIPE on platforms that require it.
Definition mxsocket.c:577
@ TYPE_INET
IPv4 stream socket.
Definition socket.hpp:41
RAII helper that initializes and shuts down the platform socket subsystem.
Definition socket.hpp:21