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
Go to the documentation of this file.
2#include <cstdlib>
3#include <iostream>
4
5int main(int argc, char **argv) {
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
ssize_t write_all(const void *buf, size_t bytes)
Write exactly the requested number of bytes.
Definition socket.cpp:203
bool connect(const std::string_view host, const std::string_view port)
Connect to a remote Internet endpoint.
Definition socket.cpp:80
int main(void)
Definition main.cpp:7
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