Source code changes.
* Changed newlines to \n. * Removed whitespace before colons. * Fixed several alignments.
This commit is contained in:
parent
b27cbd5036
commit
f24ca9a840
268 changed files with 40227 additions and 40227 deletions
|
@ -1,59 +1,59 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
void runTcpServer(unsigned short port);
|
||||
void runTcpClient(unsigned short port);
|
||||
void runUdpServer(unsigned short port);
|
||||
void runUdpClient(unsigned short port);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
///
|
||||
/// \return Application exit code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Choose an arbitrary port for opening sockets
|
||||
const unsigned short port = 50001;
|
||||
|
||||
// TCP, UDP or connected UDP ?
|
||||
char protocol;
|
||||
std::cout << "Do you want to use TCP (t) or UDP (u) ? ";
|
||||
std::cin >> protocol;
|
||||
|
||||
// Client or server ?
|
||||
char who;
|
||||
std::cout << "Do you want to be a server (s) or a client (c) ? ";
|
||||
std::cin >> who;
|
||||
|
||||
if (protocol == 't')
|
||||
{
|
||||
// Test the TCP protocol
|
||||
if (who == 's')
|
||||
runTcpServer(port);
|
||||
else
|
||||
runTcpClient(port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test the unconnected UDP protocol
|
||||
if (who == 's')
|
||||
runUdpServer(port);
|
||||
else
|
||||
runUdpClient(port);
|
||||
}
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
std::cout << "Press enter to exit..." << std::endl;
|
||||
std::cin.ignore(10000, '\n');
|
||||
std::cin.ignore(10000, '\n');
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
void runTcpServer(unsigned short port);
|
||||
void runTcpClient(unsigned short port);
|
||||
void runUdpServer(unsigned short port);
|
||||
void runUdpClient(unsigned short port);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
///
|
||||
/// \return Application exit code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Choose an arbitrary port for opening sockets
|
||||
const unsigned short port = 50001;
|
||||
|
||||
// TCP, UDP or connected UDP ?
|
||||
char protocol;
|
||||
std::cout << "Do you want to use TCP (t) or UDP (u) ? ";
|
||||
std::cin >> protocol;
|
||||
|
||||
// Client or server ?
|
||||
char who;
|
||||
std::cout << "Do you want to be a server (s) or a client (c) ? ";
|
||||
std::cin >> who;
|
||||
|
||||
if (protocol == 't')
|
||||
{
|
||||
// Test the TCP protocol
|
||||
if (who == 's')
|
||||
runTcpServer(port);
|
||||
else
|
||||
runTcpClient(port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test the unconnected UDP protocol
|
||||
if (who == 's')
|
||||
runUdpServer(port);
|
||||
else
|
||||
runUdpClient(port);
|
||||
}
|
||||
|
||||
// Wait until the user presses 'enter' key
|
||||
std::cout << "Press enter to exit..." << std::endl;
|
||||
std::cin.ignore(10000, '\n');
|
||||
std::cin.ignore(10000, '\n');
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue