Changed the naming convention for public member variables/functions and free functions (using lowerCase instead of UpperCase)
This commit is contained in:
parent
ff5b69d312
commit
14ac411542
200 changed files with 4302 additions and 4320 deletions
|
@ -154,7 +154,7 @@ public :
|
|||
/// \return True if the status is a success, false if it is a failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsOk() const;
|
||||
bool isOk() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the status code of the response
|
||||
|
@ -162,7 +162,7 @@ public :
|
|||
/// \return Status code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the full message contained in the response
|
||||
|
@ -170,7 +170,7 @@ public :
|
|||
/// \return The response message
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetMessage() const;
|
||||
const std::string& getMessage() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -203,7 +203,7 @@ public :
|
|||
/// \return Directory name
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetDirectory() const;
|
||||
const std::string& getDirectory() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -237,7 +237,7 @@ public :
|
|||
/// \return Array containing the requested filenames
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::vector<std::string>& GetFilenames() const;
|
||||
const std::vector<std::string>& getFilenames() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -275,20 +275,20 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Disconnect
|
||||
/// \see disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);
|
||||
Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the connection with the server
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Connect
|
||||
/// \see connect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Disconnect();
|
||||
Response disconnect();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Log in using an anonymous account
|
||||
|
@ -299,7 +299,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Login();
|
||||
Response login();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Log in using a username and a password
|
||||
|
@ -313,7 +313,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Login(const std::string& name, const std::string& password);
|
||||
Response login(const std::string& name, const std::string& password);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a null command to keep the connection alive
|
||||
|
@ -324,7 +324,7 @@ public :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response KeepAlive();
|
||||
Response keepAlive();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current working directory
|
||||
|
@ -334,10 +334,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetDirectoryListing, ChangeDirectory, ParentDirectory
|
||||
/// \see getDirectoryListing, changeDirectory, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
DirectoryResponse GetWorkingDirectory();
|
||||
DirectoryResponse getWorkingDirectory();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the contents of the given directory
|
||||
|
@ -351,10 +351,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, ChangeDirectory, ParentDirectory
|
||||
/// \see getWorkingDirectory, changeDirectory, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ListingResponse GetDirectoryListing(const std::string& directory = "");
|
||||
ListingResponse getDirectoryListing(const std::string& directory = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current working directory
|
||||
|
@ -365,20 +365,20 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, GetDirectoryListing, ParentDirectory
|
||||
/// \see getWorkingDirectory, getDirectoryListing, parentDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response ChangeDirectory(const std::string& directory);
|
||||
Response changeDirectory(const std::string& directory);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Go to the parent directory of the current one
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see GetWorkingDirectory, GetDirectoryListing, ChangeDirectory
|
||||
/// \see getWorkingDirectory, getDirectoryListing, changeDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response ParentDirectory();
|
||||
Response parentDirectory();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create a new directory
|
||||
|
@ -390,10 +390,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see DeleteDirectory
|
||||
/// \see deleteDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response CreateDirectory(const std::string& name);
|
||||
Response createDirectory(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove an existing directory
|
||||
|
@ -407,10 +407,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see CreateDirectory
|
||||
/// \see createDirectory
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response DeleteDirectory(const std::string& name);
|
||||
Response deleteDirectory(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Rename an existing file
|
||||
|
@ -423,10 +423,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see DeleteFile
|
||||
/// \see deleteFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response RenameFile(const std::string& file, const std::string& newName);
|
||||
Response renameFile(const std::string& file, const std::string& newName);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove an existing file
|
||||
|
@ -440,10 +440,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see RenameFile
|
||||
/// \see renameFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response DeleteFile(const std::string& name);
|
||||
Response deleteFile(const std::string& name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Download a file from the server
|
||||
|
@ -459,10 +459,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see Upload
|
||||
/// \see upload
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
||||
Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Upload a file to the server
|
||||
|
@ -478,8 +478,10 @@ public :
|
|||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
/// \see download
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response Upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
|
||||
Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -492,7 +494,7 @@ private :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response SendCommand(const std::string& command, const std::string& parameter = "");
|
||||
Response sendCommand(const std::string& command, const std::string& parameter = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a response from the server
|
||||
|
@ -503,7 +505,7 @@ private :
|
|||
/// \return Server response to the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response GetResponse();
|
||||
Response getResponse();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Utility class for exchanging datas with the server
|
||||
|
@ -543,11 +545,11 @@ private :
|
|||
///
|
||||
/// Every command returns a FTP response, which contains the
|
||||
/// status code as well as a message from the server. Some
|
||||
/// commands such as GetWorkingDirectory and GetDirectoryListing
|
||||
/// commands such as getWorkingDirectory and getDirectoryListing
|
||||
/// return additional data, and use a class derived from
|
||||
/// sf::Ftp::Response to provide this data.
|
||||
///
|
||||
/// All commands, especially Upload and Download, may take some
|
||||
/// All commands, especially upload and download, may take some
|
||||
/// time to complete. This is important to know if you don't want
|
||||
/// to block your application while the server is completing
|
||||
/// the task.
|
||||
|
@ -558,32 +560,32 @@ private :
|
|||
/// sf::Ftp ftp;
|
||||
///
|
||||
/// // Connect to the server
|
||||
/// sf::Ftp::Response response = ftp.Connect("ftp://ftp.myserver.com");
|
||||
/// if (response.IsOk())
|
||||
/// sf::Ftp::Response response = ftp.connect("ftp://ftp.myserver.com");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Connected" << std::endl;
|
||||
///
|
||||
/// // Log in
|
||||
/// response = ftp.Login("laurent", "dF6Zm89D");
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.login("laurent", "dF6Zm89D");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Logged in" << std::endl;
|
||||
///
|
||||
/// // Print the working directory
|
||||
/// sf::Ftp::DirectoryResponse directory = ftp.GetWorkingDirectory();
|
||||
/// if (directory.IsOk())
|
||||
/// std::cout << "Working directory: " << directory.GetDirectory() << std::endl;
|
||||
/// sf::Ftp::DirectoryResponse directory = ftp.getWorkingDirectory();
|
||||
/// if (directory.isOk())
|
||||
/// std::cout << "Working directory: " << directory.getDirectory() << std::endl;
|
||||
///
|
||||
/// // Create a new directory
|
||||
/// response = ftp.CreateDirectory("files");
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.createDirectory("files");
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "Created new directory" << std::endl;
|
||||
///
|
||||
/// // Upload a file to this new directory
|
||||
/// response = ftp.Upload("local-path/file.txt", "files", sf::Ftp::Ascii);
|
||||
/// if (response.IsOk())
|
||||
/// response = ftp.upload("local-path/file.txt", "files", sf::Ftp::Ascii);
|
||||
/// if (response.isOk())
|
||||
/// std::cout << "File uploaded" << std::endl;
|
||||
///
|
||||
/// // Disconnect from the server (optional)
|
||||
/// ftp.Disconnect();
|
||||
/// ftp.disconnect();
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -92,7 +92,7 @@ public :
|
|||
/// \param value Value of the field
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetField(const std::string& field, const std::string& value);
|
||||
void setField(const std::string& field, const std::string& value);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the request method
|
||||
|
@ -104,7 +104,7 @@ public :
|
|||
/// \param method Method to use for the request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetMethod(Method method);
|
||||
void setMethod(Method method);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the requested URI
|
||||
|
@ -116,7 +116,7 @@ public :
|
|||
/// \param uri URI to request, relative to the host
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetUri(const std::string& uri);
|
||||
void setUri(const std::string& uri);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the HTTP version for the request
|
||||
|
@ -127,7 +127,7 @@ public :
|
|||
/// \param minor Minor HTTP version number
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetHttpVersion(unsigned int major, unsigned int minor);
|
||||
void setHttpVersion(unsigned int major, unsigned int minor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the body of the request
|
||||
|
@ -139,7 +139,7 @@ public :
|
|||
/// \param body Content of the body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetBody(const std::string& body);
|
||||
void setBody(const std::string& body);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -154,7 +154,7 @@ public :
|
|||
/// \return String containing the request, ready to be sent
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string Prepare() const;
|
||||
std::string prepare() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the request defines a field
|
||||
|
@ -166,7 +166,7 @@ public :
|
|||
/// \return True if the field exists, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool HasField(const std::string& field) const;
|
||||
bool hasField(const std::string& field) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -178,7 +178,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
FieldTable m_fields; ///< Fields of the header associated to their value
|
||||
Method m_method; ///< Method to use for the request
|
||||
std::string m_uRI; ///< Target URI of the request
|
||||
std::string m_uri; ///< Target URI of the request
|
||||
unsigned int m_majorVersion; ///< Major HTTP version
|
||||
unsigned int m_minorVersion; ///< Minor HTTP version
|
||||
std::string m_body; ///< Body of the request
|
||||
|
@ -252,7 +252,7 @@ public :
|
|||
/// \return Value of the field, or empty string if not found
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetField(const std::string& field) const;
|
||||
const std::string& getField(const std::string& field) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the response status code
|
||||
|
@ -265,27 +265,27 @@ public :
|
|||
/// \return Status code of the response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status GetStatus() const;
|
||||
Status getStatus() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the major HTTP version number of the response
|
||||
///
|
||||
/// \return Major HTTP version number
|
||||
///
|
||||
/// \see GetMinorHttpVersion
|
||||
/// \see getMinorHttpVersion
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetMajorHttpVersion() const;
|
||||
unsigned int getMajorHttpVersion() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the minor HTTP version number of the response
|
||||
///
|
||||
/// \return Minor HTTP version number
|
||||
///
|
||||
/// \see GetMajorHttpVersion
|
||||
/// \see getMajorHttpVersion
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetMinorHttpVersion() const;
|
||||
unsigned int getMinorHttpVersion() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the body of the response
|
||||
|
@ -299,7 +299,7 @@ public :
|
|||
/// \return The response body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const std::string& GetBody() const;
|
||||
const std::string& getBody() const;
|
||||
|
||||
private :
|
||||
|
||||
|
@ -314,7 +314,7 @@ public :
|
|||
/// \param data Content of the response to parse
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Parse(const std::string& data);
|
||||
void parse(const std::string& data);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
|
@ -368,7 +368,7 @@ public :
|
|||
/// \param port Port to use for connection
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetHost(const std::string& host, unsigned short port = 0);
|
||||
void setHost(const std::string& host, unsigned short port = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a HTTP request and return the server's response.
|
||||
|
@ -388,7 +388,7 @@ public :
|
|||
/// \return Server's response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response SendRequest(const Request& request, Time timeout = Time::Zero);
|
||||
Response sendRequest(const Request& request, Time timeout = Time::Zero);
|
||||
|
||||
private :
|
||||
|
||||
|
@ -444,19 +444,19 @@ private :
|
|||
/// sf::Http http;
|
||||
///
|
||||
/// // We'll work on http://www.sfml-dev.org
|
||||
/// http.SetHost("http://www.sfml-dev.org");
|
||||
/// http.setHost("http://www.sfml-dev.org");
|
||||
///
|
||||
/// // Prepare a request to get the 'features.php' page
|
||||
/// sf::Http::Request request("features.php");
|
||||
///
|
||||
/// // Send the request
|
||||
/// sf::Http::Response response = http.SendRequest(request);
|
||||
/// sf::Http::Response response = http.sendRequest(request);
|
||||
///
|
||||
/// // Check the status code and display the result
|
||||
/// sf::Http::Response::Status status = response.GetStatus();
|
||||
/// sf::Http::Response::Status status = response.getStatus();
|
||||
/// if (status == sf::Http::Response::Ok)
|
||||
/// {
|
||||
/// std::cout << response.GetBody() << std::endl;
|
||||
/// std::cout << response.getBody() << std::endl;
|
||||
/// }
|
||||
/// else
|
||||
/// {
|
||||
|
|
|
@ -103,7 +103,7 @@ public :
|
|||
///
|
||||
/// \param address 4 bytes of the address packed into a 32-bits integer
|
||||
///
|
||||
/// \see ToInteger
|
||||
/// \see toInteger
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit IpAddress(Uint32 address);
|
||||
|
@ -117,10 +117,10 @@ public :
|
|||
///
|
||||
/// \return String representation of the address
|
||||
///
|
||||
/// \see ToInteger
|
||||
/// \see toInteger
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::string ToString() const;
|
||||
std::string toString() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get an integer representation of the address
|
||||
|
@ -133,10 +133,10 @@ public :
|
|||
///
|
||||
/// \return 32-bits unsigned integer representation of the address
|
||||
///
|
||||
/// \see ToString
|
||||
/// \see toString
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint32 ToInteger() const;
|
||||
Uint32 toInteger() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the computer's local address
|
||||
|
@ -144,15 +144,15 @@ public :
|
|||
/// The local address is the address of the computer from the
|
||||
/// LAN point of view, i.e. something like 192.168.1.56. It is
|
||||
/// meaningful only for communications over the local network.
|
||||
/// Unlike GetPublicAddress, this function is fast and may be
|
||||
/// Unlike getPublicAddress, this function is fast and may be
|
||||
/// used safely anywhere.
|
||||
///
|
||||
/// \return Local IP address of the computer
|
||||
///
|
||||
/// \see GetPublicAddress
|
||||
/// \see getPublicAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static IpAddress GetLocalAddress();
|
||||
static IpAddress getLocalAddress();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the computer's public address
|
||||
|
@ -173,10 +173,10 @@ public :
|
|||
///
|
||||
/// \return Public IP address of the computer
|
||||
///
|
||||
/// \see GetLocalAddress
|
||||
/// \see getLocalAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static IpAddress GetPublicAddress(Time timeout = Time::Zero);
|
||||
static IpAddress getPublicAddress(Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Static member data
|
||||
|
@ -306,8 +306,8 @@ SFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress
|
|||
/// sf::IpAddress a5("my_computer"); // a local address created from a network name
|
||||
/// sf::IpAddress a6("89.54.1.169"); // a distant address
|
||||
/// sf::IpAddress a7("www.google.com"); // a distant address created from a network name
|
||||
/// sf::IpAddress a8 = sf::IpAddress::GetLocalAddress(); // my address on the local network
|
||||
/// sf::IpAddress a9 = sf::IpAddress::GetPublicAddress(); // my address on the internet
|
||||
/// sf::IpAddress a8 = sf::IpAddress::getLocalAddress(); // my address on the local network
|
||||
/// sf::IpAddress a9 = sf::IpAddress::getPublicAddress(); // my address on the internet
|
||||
/// \endcode
|
||||
///
|
||||
/// Note that sf::IpAddress currently doesn't support IPv6
|
||||
|
|
|
@ -71,20 +71,20 @@ public :
|
|||
/// \param data Pointer to the sequence of bytes to append
|
||||
/// \param sizeInBytes Number of bytes to append
|
||||
///
|
||||
/// \see Clear
|
||||
/// \see clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Append(const void* data, std::size_t sizeInBytes);
|
||||
void append(const void* data, std::size_t sizeInBytes);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Clear the packet
|
||||
///
|
||||
/// After calling Clear, the packet is empty.
|
||||
///
|
||||
/// \see Append
|
||||
/// \see append
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a pointer to the data contained in the packet
|
||||
|
@ -96,23 +96,23 @@ public :
|
|||
///
|
||||
/// \return Pointer to the data
|
||||
///
|
||||
/// \see GetDataSize
|
||||
/// \see getDataSize
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* GetData() const;
|
||||
const char* getData() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the size of the data contained in the packet
|
||||
///
|
||||
/// This function returns the number of bytes pointed to by
|
||||
/// what GetData returns.
|
||||
/// what getData returns.
|
||||
///
|
||||
/// \return Data size, in bytes
|
||||
///
|
||||
/// \see GetData
|
||||
/// \see getData
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetDataSize() const;
|
||||
std::size_t getDataSize() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell if the reading position has reached the
|
||||
|
@ -126,7 +126,7 @@ public :
|
|||
/// \see operator bool
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool EndOfPacket() const;
|
||||
bool endOfPacket() const;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
///
|
||||
/// \return True if last data extraction from packet was successful
|
||||
///
|
||||
/// \see EndOfPacket
|
||||
/// \see endOfPacket
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
operator BoolType() const;
|
||||
|
@ -230,7 +230,7 @@ private :
|
|||
/// \return True if \a size bytes can be read from the packet
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool CheckSize(std::size_t size);
|
||||
bool checkSize(std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called before the packet is sent over the network
|
||||
|
@ -247,10 +247,10 @@ private :
|
|||
///
|
||||
/// \return Pointer to the array of bytes to send
|
||||
///
|
||||
/// \see OnReceive
|
||||
/// \see onReceive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual const char* OnSend(std::size_t& size);
|
||||
virtual const char* onSend(std::size_t& size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called after the packet is received over the network
|
||||
|
@ -266,8 +266,10 @@ private :
|
|||
/// \param data Pointer to the received bytes
|
||||
/// \param size Number of bytes
|
||||
///
|
||||
/// \see onSend
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnReceive(const char* data, std::size_t size);
|
||||
virtual void onReceive(const char* data, std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
|
@ -316,13 +318,13 @@ private :
|
|||
/// packet << x << s << d;
|
||||
///
|
||||
/// // Send it over the network (socket is a valid sf::TcpSocket)
|
||||
/// socket.Send(packet);
|
||||
/// socket.send(packet);
|
||||
///
|
||||
/// -----------------------------------------------------------------
|
||||
///
|
||||
/// // Receive the packet at the other end
|
||||
/// sf::Packet packet;
|
||||
/// socket.Receive(packet);
|
||||
/// socket.receive(packet);
|
||||
///
|
||||
/// // Extract the variables contained in the packet
|
||||
/// sf::Uint32 x;
|
||||
|
@ -369,26 +371,26 @@ private :
|
|||
/// and after it is received. This is typically used to
|
||||
/// handle automatic compression or encryption of the data.
|
||||
/// This is achieved by inheriting from sf::Packet, and overriding
|
||||
/// the OnSend and OnReceive functions.
|
||||
/// the onSend and onReceive functions.
|
||||
///
|
||||
/// Here is an example:
|
||||
/// \code
|
||||
/// class ZipPacket : public sf::Packet
|
||||
/// {
|
||||
/// virtual const char* OnSend(std::size_t& size)
|
||||
/// virtual const char* onSend(std::size_t& size)
|
||||
/// {
|
||||
/// const char* srcData = GetData();
|
||||
/// std::size_t srcSize = GetDataSize();
|
||||
/// const char* srcData = getData();
|
||||
/// std::size_t srcSize = getDataSize();
|
||||
///
|
||||
/// return MySuperZipFunction(srcData, srcSize, &size);
|
||||
/// }
|
||||
///
|
||||
/// virtual void OnReceive(const char* data, std::size_t size)
|
||||
/// virtual void onReceive(const char* data, std::size_t size)
|
||||
/// {
|
||||
/// std::size_t dstSize;
|
||||
/// const char* dstData = MySuperUnzipFunction(data, size, &dstSize);
|
||||
///
|
||||
/// Append(dstData, dstSize);
|
||||
/// append(dstData, dstSize);
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
|
|
|
@ -89,20 +89,20 @@ public :
|
|||
///
|
||||
/// \param blocking True to set the socket as blocking, false for non-blocking
|
||||
///
|
||||
/// \see IsBlocking
|
||||
/// \see isBlocking
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetBlocking(bool blocking);
|
||||
void setBlocking(bool blocking);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Tell whether the socket is in blocking or non-blocking mode
|
||||
///
|
||||
/// \return True if the socket is blocking, false otherwise
|
||||
///
|
||||
/// \see SetBlocking
|
||||
/// \see setBlocking
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsBlocking() const;
|
||||
bool isBlocking() const;
|
||||
|
||||
protected :
|
||||
|
||||
|
@ -136,7 +136,7 @@ protected :
|
|||
/// \return The internal (OS-specific) handle of the socket
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SocketHandle GetHandle() const;
|
||||
SocketHandle getHandle() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the internal representation of the socket
|
||||
|
@ -144,7 +144,7 @@ protected :
|
|||
/// This function can only be accessed by derived classes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create();
|
||||
void create();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the internal representation of the socket
|
||||
|
@ -155,7 +155,7 @@ protected :
|
|||
/// \param handle OS-specific handle of the socket to wrap
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(SocketHandle handle);
|
||||
void create(SocketHandle handle);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the socket gracefully
|
||||
|
@ -163,7 +163,7 @@ protected :
|
|||
/// This function can only be accessed by derived classes.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Close();
|
||||
void close();
|
||||
|
||||
private :
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ public :
|
|||
///
|
||||
/// \param socket Reference to the socket to add
|
||||
///
|
||||
/// \see Remove, Clear
|
||||
/// \see remove, clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Add(Socket& socket);
|
||||
void add(Socket& socket);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove a socket from the selector
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
///
|
||||
/// \param socket Reference to the socket to remove
|
||||
///
|
||||
/// \see Add, Clear
|
||||
/// \see add, clear
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Remove(Socket& socket);
|
||||
void remove(Socket& socket);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Remove all the sockets stored in the selector
|
||||
|
@ -98,17 +98,17 @@ public :
|
|||
/// removes all the references that the selector has to
|
||||
/// external sockets.
|
||||
///
|
||||
/// \see Add, Remove
|
||||
/// \see add, remove
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Wait until one or more sockets are ready to receive
|
||||
///
|
||||
/// This function returns as soon as at least one socket has
|
||||
/// some data available to be received. To know which sockets are
|
||||
/// ready, use the IsReady function.
|
||||
/// ready, use the isReady function.
|
||||
/// If you use a timeout and no socket is ready before the timeout
|
||||
/// is over, the function returns false.
|
||||
///
|
||||
|
@ -116,17 +116,17 @@ public :
|
|||
///
|
||||
/// \return True if there are sockets ready, false otherwise
|
||||
///
|
||||
/// \see IsReady
|
||||
/// \see isReady
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Wait(Time timeout = Time::Zero);
|
||||
bool wait(Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Test a socket to know if it is ready to receive data
|
||||
///
|
||||
/// This function must be used after a call to Wait, to know
|
||||
/// which sockets are ready to receive data. If a socket is
|
||||
/// ready, a call to Receive will never block because we know
|
||||
/// ready, a call to receive will never block because we know
|
||||
/// that there is data available to read.
|
||||
/// Note that if this function returns true for a TcpListener,
|
||||
/// this means that it is ready to accept a new connection.
|
||||
|
@ -135,10 +135,10 @@ public :
|
|||
///
|
||||
/// \return True if the socket is ready to read, false otherwise
|
||||
///
|
||||
/// \see IsReady
|
||||
/// \see isReady
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsReady(Socket& socket) const;
|
||||
bool isReady(Socket& socket) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
|
@ -199,7 +199,7 @@ private :
|
|||
/// \code
|
||||
/// // Create a socket to listen to new connections
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Create a list to store the future clients
|
||||
/// std::list<sf::TcpSocket*> clients;
|
||||
|
@ -208,16 +208,16 @@ private :
|
|||
/// sf::SocketSelector selector;
|
||||
///
|
||||
/// // Add the listener to the selector
|
||||
/// selector.Add(listener);
|
||||
/// selector.add(listener);
|
||||
///
|
||||
/// // Endless loop that waits for new connections
|
||||
/// while (running)
|
||||
/// {
|
||||
/// // Make the selector wait for data on any socket
|
||||
/// if (selector.Wait())
|
||||
/// if (selector.wait())
|
||||
/// {
|
||||
/// // Test the listener
|
||||
/// if (selector.IsReady(listener))
|
||||
/// if (selector.isReady(listener))
|
||||
/// {
|
||||
/// // The listener is ready: there is a pending connection
|
||||
/// sf::TcpSocket* client = new sf::TcpSocket;
|
||||
|
@ -228,7 +228,7 @@ private :
|
|||
///
|
||||
/// // Add the new client to the selector so that we will
|
||||
/// // be notified when he sends something
|
||||
/// selector.Add(*client);
|
||||
/// selector.add(*client);
|
||||
/// }
|
||||
/// }
|
||||
/// else
|
||||
|
@ -237,11 +237,11 @@ private :
|
|||
/// for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
|
||||
/// {
|
||||
/// sf::TcpSocket& client = **it;
|
||||
/// if (selector.IsReady(client))
|
||||
/// if (selector.isReady(client))
|
||||
/// {
|
||||
/// // The client has sent some data, we can receive it
|
||||
/// sf::Packet packet;
|
||||
/// if (client.Receive(packet) == sf::Socket::Done)
|
||||
/// if (client.receive(packet) == sf::Socket::Done)
|
||||
/// {
|
||||
/// ...
|
||||
/// }
|
||||
|
|
|
@ -58,10 +58,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Start listening for connections
|
||||
|
@ -75,10 +75,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Accept, Close
|
||||
/// \see accept, close
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Listen(unsigned short port);
|
||||
Status listen(unsigned short port);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop listening and close the socket
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
/// This function gracefully stops the listener. If the
|
||||
/// socket is not listening, this function has no effect.
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Close();
|
||||
void close();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Accept a new connection
|
||||
|
@ -101,10 +101,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Listen
|
||||
/// \see listen
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Accept(TcpSocket& socket);
|
||||
Status accept(TcpSocket& socket);
|
||||
};
|
||||
|
||||
|
||||
|
@ -122,7 +122,7 @@ public :
|
|||
/// a given port and waits for connections on that port.
|
||||
/// This is all it can do.
|
||||
///
|
||||
/// When a new connection is received, you must call Accept and
|
||||
/// When a new connection is received, you must call accept and
|
||||
/// the listener returns a new instance of sf::TcpSocket that
|
||||
/// is properly initialized and can be used to communicate with
|
||||
/// the new client.
|
||||
|
@ -134,7 +134,7 @@ public :
|
|||
///
|
||||
/// A listener is automatically closed on destruction, like all
|
||||
/// other types of socket. However if you want to stop listening
|
||||
/// before the socket is destroyed, you can call its Close()
|
||||
/// before the socket is destroyed, you can call its close()
|
||||
/// function.
|
||||
///
|
||||
/// Usage example:
|
||||
|
@ -142,17 +142,17 @@ public :
|
|||
/// // Create a listener socket and make it wait for new
|
||||
/// // connections on port 55001
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Endless loop that waits for new connections
|
||||
/// while (running)
|
||||
/// {
|
||||
/// sf::TcpSocket client;
|
||||
/// if (listener.Accept(client) == sf::Socket::Done)
|
||||
/// if (listener.accept(client) == sf::Socket::Done)
|
||||
/// {
|
||||
/// // A new client just connected!
|
||||
/// std::cout << "New connection received from " << client.GetRemoteAddress() << std::endl;
|
||||
/// DoSomethingWith(client);
|
||||
/// std::cout << "New connection received from " << client.getRemoteAddress() << std::endl;
|
||||
/// doSomethingWith(client);
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
|
|
|
@ -60,10 +60,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Connect, GetRemotePort
|
||||
/// \see connect, getRemotePort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the address of the connected peer
|
||||
|
@ -73,10 +73,10 @@ public :
|
|||
///
|
||||
/// \return Address of the remote peer
|
||||
///
|
||||
/// \see GetRemotePort
|
||||
/// \see getRemotePort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
IpAddress GetRemoteAddress() const;
|
||||
IpAddress getRemoteAddress() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the port of the connected peer to which
|
||||
|
@ -86,10 +86,10 @@ public :
|
|||
///
|
||||
/// \return Remote port to which the socket is connected
|
||||
///
|
||||
/// \see GetRemoteAddress
|
||||
/// \see getRemoteAddress
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetRemotePort() const;
|
||||
unsigned short getRemotePort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Connect the socket to a remote peer
|
||||
|
@ -105,10 +105,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Disconnect
|
||||
/// \see disconnect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);
|
||||
Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Disconnect the socket from its remote peer
|
||||
|
@ -119,7 +119,7 @@ public :
|
|||
/// \see Connect
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Disconnect();
|
||||
void disconnect();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send raw data to the remote peer
|
||||
|
@ -131,10 +131,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(const char* data, std::size_t size);
|
||||
Status send(const char* data, std::size_t size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive raw data from the remote peer
|
||||
|
@ -149,10 +149,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(char* data, std::size_t size, std::size_t& received);
|
||||
Status receive(char* data, std::size_t size, std::size_t& received);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a formatted packet of data to the remote peer
|
||||
|
@ -163,10 +163,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(Packet& packet);
|
||||
Status send(Packet& packet);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a formatted packet of data from the remote peer
|
||||
|
@ -179,10 +179,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(Packet& packet);
|
||||
Status receive(Packet& packet);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -227,10 +227,10 @@ private:
|
|||
///
|
||||
/// When a socket is connected to a remote host, you can
|
||||
/// retrieve informations about this host with the
|
||||
/// GetRemoteAddress and GetRemotePort functions. You can
|
||||
/// getRemoteAddress and GetRemotePort functions. You can
|
||||
/// also get the local port to which the socket is bound
|
||||
/// (which is automatically chosen when the socket is connected),
|
||||
/// with the GetLocalPort function.
|
||||
/// with the getLocalPort function.
|
||||
///
|
||||
/// Sending and receiving data can use either the low-level
|
||||
/// or the high-level functions. The low-level functions
|
||||
|
@ -245,7 +245,7 @@ private:
|
|||
///
|
||||
/// The socket is automatically disconnected when it is destroyed,
|
||||
/// but if you want to explicitely close the connection while
|
||||
/// the socket instance is still alive, you can call Disconnect.
|
||||
/// the socket instance is still alive, you can call disconnect.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
|
@ -253,38 +253,38 @@ private:
|
|||
///
|
||||
/// // Create a socket and connect it to 192.168.1.50 on port 55001
|
||||
/// sf::TcpSocket socket;
|
||||
/// socket.Connect("192.168.1.50", 55001);
|
||||
/// socket.connect("192.168.1.50", 55001);
|
||||
///
|
||||
/// // Send a message to the connected host
|
||||
/// std::string message = "Hi, I am a client";
|
||||
/// socket.Send(message.c_str(), message.size() + 1);
|
||||
/// socket.send(message.c_str(), message.size() + 1);
|
||||
///
|
||||
/// // Receive an answer from the server
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received);
|
||||
/// socket.receive(buffer, sizeof(buffer), received);
|
||||
/// std::cout << "The server said: " << buffer << std::endl;
|
||||
///
|
||||
/// // ----- The server -----
|
||||
///
|
||||
/// // Create a listener to wait for incoming connections on port 55001
|
||||
/// sf::TcpListener listener;
|
||||
/// listener.Listen(55001);
|
||||
/// listener.listen(55001);
|
||||
///
|
||||
/// // Wait for a connection
|
||||
/// sf::TcpSocket socket;
|
||||
/// listener.Accept(socket);
|
||||
/// std::cout << "New client connected: " << socket.GetRemoteAddress() << std::endl;
|
||||
/// listener.accept(socket);
|
||||
/// std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl;
|
||||
///
|
||||
/// // Receive a message from the client
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received);
|
||||
/// socket.receive(buffer, sizeof(buffer), received);
|
||||
/// std::cout << "The client said: " << buffer << std::endl;
|
||||
///
|
||||
/// // Send an answer
|
||||
/// std::string message = "Welcome, client";
|
||||
/// socket.Send(message.c_str(), message.size() + 1);
|
||||
/// socket.send(message.c_str(), message.size() + 1);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Socket, sf::UdpSocket, sf::Packet
|
||||
|
|
|
@ -68,10 +68,10 @@ public :
|
|||
///
|
||||
/// \return Port to which the socket is bound
|
||||
///
|
||||
/// \see Bind
|
||||
/// \see bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned short GetLocalPort() const;
|
||||
unsigned short getLocalPort() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Bind the socket to a specific port
|
||||
|
@ -80,16 +80,16 @@ public :
|
|||
/// able to receive data on that port.
|
||||
/// You can use the special value Socket::AnyPort to tell the
|
||||
/// system to automatically pick an available port, and then
|
||||
/// call GetLocalPort to retrieve the chosen port.
|
||||
/// call getLocalPort to retrieve the chosen port.
|
||||
///
|
||||
/// \param port Port to bind the socket to
|
||||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Unbind, GetLocalPort
|
||||
/// \see unbind, getLocalPort
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Bind(unsigned short port);
|
||||
Status bind(unsigned short port);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Unbind the socket from the local port to which it is bound
|
||||
|
@ -98,10 +98,10 @@ public :
|
|||
/// available after this function is called. If the
|
||||
/// socket is not bound to a port, this function has no effect.
|
||||
///
|
||||
/// \see Bind
|
||||
/// \see bind
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Unbind();
|
||||
void unbind();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send raw data to a remote peer
|
||||
|
@ -117,10 +117,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(const char* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
Status send(const char* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive raw data from a remote peer
|
||||
|
@ -140,10 +140,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(char* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
Status receive(char* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a formatted packet of data to a remote peer
|
||||
|
@ -158,18 +158,16 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Receive
|
||||
/// \see receive
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
Status send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Receive a formatted packet of data from a remote peer
|
||||
///
|
||||
/// In blocking mode, this function will wait until the whole packet
|
||||
/// has been received.
|
||||
/// Warning: this functon doesn't properly handle mixed data
|
||||
/// received from multiple peers.
|
||||
///
|
||||
/// \param packet Packet to fill with the received data
|
||||
/// \param remoteAddress Address of the peer that sent the data
|
||||
|
@ -177,10 +175,10 @@ public :
|
|||
///
|
||||
/// \return Status code
|
||||
///
|
||||
/// \see Send
|
||||
/// \see send
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Status Receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
Status receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -206,8 +204,8 @@ private:
|
|||
///
|
||||
/// It is a datagram protocol: bounded blocks of data (datagrams)
|
||||
/// are transfered over the network rather than a continuous
|
||||
/// stream of data (TCP). Therefore, one call to Send will always
|
||||
/// match one call to Receive (if the datagram is not lost),
|
||||
/// stream of data (TCP). Therefore, one call to send will always
|
||||
/// match one call to receive (if the datagram is not lost),
|
||||
/// with the same data that was sent.
|
||||
///
|
||||
/// The UDP protocol is lightweight but unreliable. Unreliable
|
||||
|
@ -247,37 +245,37 @@ private:
|
|||
///
|
||||
/// // Create a socket and bind it to the port 55001
|
||||
/// sf::UdpSocket socket;
|
||||
/// socket.Bind(55001);
|
||||
/// socket.bind(55001);
|
||||
///
|
||||
/// // Send a message to 192.168.1.50 on port 55002
|
||||
/// std::string message = "Hi, I am " + sf::IpAddress::GetLocalAddress().ToString();
|
||||
/// socket.Send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
|
||||
/// std::string message = "Hi, I am " + sf::IpAddress::getLocalAddress().toString();
|
||||
/// socket.send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
|
||||
///
|
||||
/// // Receive an answer (most likely from 192.168.1.50, but could be anyone else)
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// sf::IpAddress sender;
|
||||
/// unsigned short port;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
|
||||
///
|
||||
/// // ----- The server -----
|
||||
///
|
||||
/// // Create a socket and bind it to the port 55002
|
||||
/// sf::UdpSocket socket;
|
||||
/// socket.Bind(55002);
|
||||
/// socket.bind(55002);
|
||||
///
|
||||
/// // Receive a message from anyone
|
||||
/// char buffer[1024];
|
||||
/// std::size_t received = 0;
|
||||
/// sf::IpAddress sender;
|
||||
/// unsigned short port;
|
||||
/// socket.Receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// socket.receive(buffer, sizeof(buffer), received, sender, port);
|
||||
/// std::cout << sender.ToString() << " said: " << buffer << std::endl;
|
||||
///
|
||||
/// // Send an answer
|
||||
/// std::string message = "Welcome " + sender.ToString();
|
||||
/// socket.Send(message.c_str(), message.size() + 1, sender, port);
|
||||
/// std::string message = "Welcome " + sender.toString();
|
||||
/// socket.send(message.c_str(), message.size() + 1, sender, port);
|
||||
/// \endcode
|
||||
///
|
||||
/// \see sf::Socket, sf::TcpSocket, sf::Packet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue