MCPcopy Create free account
hub / github.com/SFML/SFML / main

Function main

examples/sockets/Sockets.cpp:16–57  ·  view source on GitHub ↗

/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

14///
15////////////////////////////////////////////////////////////
16int main()
17{
18 // Choose an arbitrary port for opening sockets
19 const unsigned short port = 50001;
20
21 // TCP, UDP or connected UDP ?
22 char protocol = 0;
23 std::cout << "Do you want to use TCP (t) or UDP (u)? ";
24 std::cin >> protocol;
25
26 // Client or server ?
27 char who = 0;
28 std::cout << "Do you want to be a server (s) or a client (c)? ";
29 std::cin >> who;
30
31 if (protocol == 't')
32 {
33 // Enable TLS ?
34 char tls = 0;
35 std::cout << "Do you want to enable TLS (y) or not (n)? ";
36 std::cin >> tls;
37
38 // Test the TCP protocol
39 if (who == 's')
40 runTcpServer(port, tls == 'y');
41 else
42 runTcpClient(port, tls == 'y');
43 }
44 else
45 {
46 // Test the unconnected UDP protocol
47 if (who == 's')
48 runUdpServer(port);
49 else
50 runUdpClient(port);
51 }
52
53 // Wait until the user presses 'enter' key
54 std::cout << "Press enter to exit..." << std::endl;
55 std::cin.ignore(10'000, '\n');
56 std::cin.ignore(10'000, '\n');
57}

Callers

nothing calls this directly

Calls 4

runTcpServerFunction · 0.85
runTcpClientFunction · 0.85
runUdpServerFunction · 0.85
runUdpClientFunction · 0.85

Tested by

no test coverage detected