Back to index

libsfml  1.6+dfsg2
VoIP.cpp
Go to the documentation of this file.
00001 
00003 // Headers
00005 #include <iomanip>
00006 #include <iostream>
00007 #include <cstdlib>
00008 
00009 
00011 // Function prototypes
00012 // (I'm too lazy to put them into separate headers...)
00014 void DoClient(unsigned short Port);
00015 void DoServer(unsigned short Port);
00016 
00017 
00024 int main()
00025 {
00026     // Choose a random port for opening sockets (ports < 1024 are reserved)
00027     const unsigned short Port = 2435;
00028 
00029     // Client or server ?
00030     char Who;
00031     std::cout << "Do you want to be a server ('s') or a client ('c') ? ";
00032     std::cin  >> Who;
00033 
00034     if (Who == 's')
00035     {
00036         // Run as a server
00037         DoServer(Port);
00038     }
00039     else
00040     {
00041         // Run as a client
00042         DoClient(Port);
00043     }
00044 
00045     // Wait until the user presses 'enter' key
00046     std::cout << "Press enter to exit..." << std::endl;
00047     std::cin.ignore(10000, '\n');
00048 
00049     return EXIT_SUCCESS;
00050 }