Improved the API documentation of sf::IpAddress

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1452 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-03-12 09:35:17 +00:00
parent b7eb09cb79
commit e924c9cf39
34 changed files with 336 additions and 264 deletions

View file

@ -26,7 +26,7 @@ std::ostream& operator <<(std::ostream& stream, const sf::Ftp::Response& respons
int main()
{
// Choose the server address
sf::IPAddress address;
sf::IpAddress address;
do
{
std::cout << "Enter the FTP server address : ";

View file

@ -13,7 +13,7 @@
void DoClientTCP(unsigned short port)
{
// Ask for server address
sf::IPAddress serverAddress;
sf::IpAddress serverAddress;
do
{
std::cout << "Type address or name of the server to connect to : ";
@ -66,7 +66,7 @@ void DoServerTCP(unsigned short port)
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
// Wait for a connection
sf::IPAddress clientAddress;
sf::IpAddress clientAddress;
sf::SocketTCP client;
if (server.Accept(client, &clientAddress) != sf::Socket::Done)
return;

View file

@ -10,28 +10,28 @@
/// Create a client and send a message to a running server
///
////////////////////////////////////////////////////////////
void DoClientUDP(unsigned short Port)
void DoClientUDP(unsigned short port)
{
// Ask for server address
sf::IPAddress ServerAddress;
sf::IpAddress serverAddress;
do
{
std::cout << "Type address or name of the server to send the message to : ";
std::cin >> ServerAddress;
std::cin >> serverAddress;
}
while (!ServerAddress.IsValid());
while (!serverAddress.IsValid());
// Create a UDP socket for communicating with server
sf::SocketUDP Client;
sf::SocketUDP client;
// Send a message to the server
char Message[] = "Hi, I'm a client !";
if (Client.Send(Message, sizeof(Message), ServerAddress, Port) != sf::Socket::Done)
char message[] = "Hi, I'm a client !";
if (client.Send(message, sizeof(message), serverAddress, port) != sf::Socket::Done)
return;
std::cout << "Message sent to server : \"" << Message << "\"" << std::endl;
std::cout << "Message sent to server : \"" << message << "\"" << std::endl;
// Close the socket when we're done
Client.Close();
client.Close();
}
@ -39,27 +39,27 @@ void DoClientUDP(unsigned short Port)
/// Launch a server and wait for incoming messages
///
////////////////////////////////////////////////////////////
void DoServerUDP(unsigned short Port)
void DoServerUDP(unsigned short port)
{
// Create a UDP socket for communicating with clients
sf::SocketUDP Server;
sf::SocketUDP server;
// Bind it to the specified port
if (!Server.Bind(Port))
if (!server.Bind(port))
return;
// Receive a message from anyone
sf::IPAddress ClientAddress;
unsigned short ClientPort;
char Message[128];
std::size_t Received;
if (Server.Receive(Message, sizeof(Message), Received, ClientAddress, ClientPort) != sf::Socket::Done)
sf::IpAddress clientAddress;
unsigned short clientPort;
char message[128];
std::size_t received;
if (server.Receive(message, sizeof(message), received, clientAddress, clientPort) != sf::Socket::Done)
return;
// Display it
std::cout << "Message received from " << ClientAddress << " on port " << ClientPort
<< ": \"" << Message << "\"" << std::endl;
std::cout << "Message received from " << clientAddress << " on port " << clientPort
<< ": \"" << message << "\"" << std::endl;
// Close the socket when we're done
Server.Close();
server.Close();
}

View file

@ -70,7 +70,7 @@ void DoClient(unsigned short port)
}
// Ask for server address
sf::IPAddress serverAddress;
sf::IpAddress serverAddress;
do
{
std::cout << "Type address or name of the server to connect to : ";

View file

@ -57,7 +57,7 @@ public :
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
// Wait for a connection
sf::IPAddress clientAddress;
sf::IpAddress clientAddress;
myListener.Accept(myClient, &clientAddress);
std::cout << "Client connected : " << clientAddress << std::endl;