summaryrefslogtreecommitdiff
path: root/include/SFML/Network
diff options
context:
space:
mode:
authorChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
committerChristoph Egger <Christoph.Egger@gmx.de>2008-11-01 17:37:58 +0100
commit9035708f4c5f7a78d8fb810e87e183fd61fd3350 (patch)
tree030e13b45c9882b799f793aa27007c74862fe934 /include/SFML/Network
parenta96b4da2ed67a3e8dcc8e2a0d9af9463a23bb021 (diff)
Imported Upstream version 1.4~svn915
Diffstat (limited to 'include/SFML/Network')
-rw-r--r--include/SFML/Network/.svn/all-wcprops71
-rw-r--r--include/SFML/Network/.svn/entries408
-rw-r--r--include/SFML/Network/.svn/format1
-rw-r--r--include/SFML/Network/.svn/text-base/Ftp.hpp.svn-base448
-rw-r--r--include/SFML/Network/.svn/text-base/Http.hpp.svn-base339
-rw-r--r--include/SFML/Network/.svn/text-base/IPAddress.hpp.svn-base229
-rw-r--r--include/SFML/Network/.svn/text-base/Packet.hpp.svn-base187
-rw-r--r--include/SFML/Network/.svn/text-base/Selector.hpp.svn-base116
-rw-r--r--include/SFML/Network/.svn/text-base/Selector.inl.svn-base97
-rw-r--r--include/SFML/Network/.svn/text-base/SelectorBase.hpp.svn-base112
-rw-r--r--include/SFML/Network/.svn/text-base/SocketHelper.hpp.svn-base64
-rw-r--r--include/SFML/Network/.svn/text-base/SocketTCP.hpp.svn-base225
-rw-r--r--include/SFML/Network/.svn/text-base/SocketUDP.hpp.svn-base224
-rw-r--r--include/SFML/Network/.svn/text-base/Sockets.hpp.svn-base45
-rw-r--r--include/SFML/Network/Ftp.hpp448
-rw-r--r--include/SFML/Network/Http.hpp339
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/IPAddress.hpp16
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Packet.hpp27
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Selector.hpp2
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Selector.inl2
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/SelectorBase.hpp2
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/SocketHelper.hpp0
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/SocketTCP.hpp14
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/SocketUDP.hpp11
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Sockets.hpp0
-rw-r--r--include/SFML/Network/Unix/.svn/all-wcprops11
-rw-r--r--include/SFML/Network/Unix/.svn/entries62
-rw-r--r--include/SFML/Network/Unix/.svn/format1
-rw-r--r--include/SFML/Network/Unix/.svn/text-base/SocketHelper.hpp.svn-base96
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Unix/SocketHelper.hpp191
-rw-r--r--include/SFML/Network/Win32/.svn/all-wcprops11
-rw-r--r--include/SFML/Network/Win32/.svn/entries62
-rw-r--r--include/SFML/Network/Win32/.svn/format1
-rw-r--r--include/SFML/Network/Win32/.svn/text-base/SocketHelper.hpp.svn-base90
-rw-r--r--[-rwxr-xr-x]include/SFML/Network/Win32/SocketHelper.hpp0
35 files changed, 3840 insertions, 112 deletions
diff --git a/include/SFML/Network/.svn/all-wcprops b/include/SFML/Network/.svn/all-wcprops
new file mode 100644
index 0000000..a3b2d70
--- /dev/null
+++ b/include/SFML/Network/.svn/all-wcprops
@@ -0,0 +1,71 @@
+K 25
+svn:wc:ra_dav:version-url
+V 47
+/svnroot/sfml/!svn/ver/912/include/SFML/Network
+END
+Ftp.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 55
+/svnroot/sfml/!svn/ver/912/include/SFML/Network/Ftp.hpp
+END
+Selector.inl
+K 25
+svn:wc:ra_dav:version-url
+V 60
+/svnroot/sfml/!svn/ver/784/include/SFML/Network/Selector.inl
+END
+SelectorBase.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/svnroot/sfml/!svn/ver/784/include/SFML/Network/SelectorBase.hpp
+END
+Sockets.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 59
+/svnroot/sfml/!svn/ver/434/include/SFML/Network/Sockets.hpp
+END
+IPAddress.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 61
+/svnroot/sfml/!svn/ver/824/include/SFML/Network/IPAddress.hpp
+END
+Http.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/svnroot/sfml/!svn/ver/908/include/SFML/Network/Http.hpp
+END
+SocketTCP.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 61
+/svnroot/sfml/!svn/ver/912/include/SFML/Network/SocketTCP.hpp
+END
+Selector.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 60
+/svnroot/sfml/!svn/ver/784/include/SFML/Network/Selector.hpp
+END
+SocketUDP.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 61
+/svnroot/sfml/!svn/ver/912/include/SFML/Network/SocketUDP.hpp
+END
+Packet.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 58
+/svnroot/sfml/!svn/ver/841/include/SFML/Network/Packet.hpp
+END
+SocketHelper.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/svnroot/sfml/!svn/ver/434/include/SFML/Network/SocketHelper.hpp
+END
diff --git a/include/SFML/Network/.svn/entries b/include/SFML/Network/.svn/entries
new file mode 100644
index 0000000..467cd32
--- /dev/null
+++ b/include/SFML/Network/.svn/entries
@@ -0,0 +1,408 @@
+9
+
+dir
+915
+https://sfml.svn.sourceforge.net/svnroot/sfml/include/SFML/Network
+https://sfml.svn.sourceforge.net/svnroot/sfml
+
+
+
+2008-10-21T18:42:24.730017Z
+912
+laurentgom
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4e206d99-4929-0410-ac5d-dfc041789085
+
+Ftp.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+52fd15b56f4a42ec1ce3e9483b8e4335
+2008-10-21T18:42:24.730017Z
+912
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+18952
+
+Selector.inl
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+ad8bac181901e307088d0b53d11c67b2
+2008-07-30T11:21:15.772571Z
+784
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3333
+
+SelectorBase.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+95b6b60886262ae3dc1902536e3d552e
+2008-07-30T11:21:15.772571Z
+784
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4114
+
+Sockets.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+3311710d5e951810ade4f0bdde415962
+2008-01-23T16:10:18.126022Z
+434
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1529
+
+Win32
+dir
+
+Unix
+dir
+
+IPAddress.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+c2df44763fb02f42aa5005bdef4e4b96
+2008-08-24T15:29:46.762411Z
+824
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8429
+
+Http.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+3567980319209dc2e7a61b53a45ba0ca
+2008-10-14T18:28:57.870558Z
+908
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14781
+
+SocketTCP.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+34e8d1cb09d3409adee1c679b3fda98f
+2008-10-21T18:42:24.730017Z
+912
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8833
+
+Selector.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+6527bb69f397be635ecd2bc22177380b
+2008-07-30T11:21:15.772571Z
+784
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4194
+
+SocketUDP.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+561c3d61bba25b28183b4fbedbfbeb48
+2008-10-21T18:42:24.730017Z
+912
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8648
+
+Packet.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+4f02358396ea606d574abd3493492554
+2008-08-30T15:01:48.265908Z
+841
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7218
+
+SocketHelper.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+12a51c3b3c68aa6daed104455a9d0d1a
+2008-01-23T16:10:18.126022Z
+434
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2113
+
diff --git a/include/SFML/Network/.svn/format b/include/SFML/Network/.svn/format
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/include/SFML/Network/.svn/format
@@ -0,0 +1 @@
+9
diff --git a/include/SFML/Network/.svn/text-base/Ftp.hpp.svn-base b/include/SFML/Network/.svn/text-base/Ftp.hpp.svn-base
new file mode 100644
index 0000000..d4bb439
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Ftp.hpp.svn-base
@@ -0,0 +1,448 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_FTP_HPP
+#define SFML_FTP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NonCopyable.hpp>
+#include <SFML/Network/SocketTCP.hpp>
+#include <string>
+#include <vector>
+
+
+namespace sf
+{
+class IPAddress;
+
+////////////////////////////////////////////////////////////
+/// This class provides methods for manipulating the FTP
+/// protocol (described in RFC 959).
+/// It provides easy access and transfers to remote
+/// directories and files on a FTP server
+////////////////////////////////////////////////////////////
+class SFML_API Ftp : NonCopyable
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumeration of transfer modes
+ ////////////////////////////////////////////////////////////
+ enum TransferMode
+ {
+ Binary, ///< Binary mode (file is transfered as a sequence of bytes)
+ Ascii, ///< Text mode using ASCII encoding
+ Ebcdic ///< Text mode using EBCDIC encoding
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps a FTP response, which is basically :
+ /// - a status code
+ /// - a message
+ ////////////////////////////////////////////////////////////
+ class Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate all the valid status codes returned in
+ /// a FTP response
+ ////////////////////////////////////////////////////////////
+ enum Status
+ {
+ // 1xx: the requested action is being initiated,
+ // expect another reply before proceeding with a new command
+ RestartMarkerReply = 110, ///< Restart marker reply
+ ServiceReadySoon = 120, ///< Service ready in N minutes
+ DataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting
+ OpeningDataConnection = 150, ///< File status ok, about to open data connection
+
+ // 2xx: the requested action has been successfully completed
+ Ok = 200, ///< Command ok
+ PointlessCommand = 202, ///< Command not implemented
+ SystemStatus = 211, ///< System status, or system help reply
+ DirectoryStatus = 212, ///< Directory status
+ FileStatus = 213, ///< File status
+ HelpMessage = 214, ///< Help message
+ SystemType = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
+ ServiceReady = 220, ///< Service ready for new user
+ ClosingConnection = 221, ///< Service closing control connection
+ DataConnectionOpened = 225, ///< Data connection open, no transfer in progress
+ ClosingDataConnection = 226, ///< Closing data connection, requested file action successful
+ EnteringPassiveMode = 227, ///< Entering passive mode
+ LoggedIn = 230, ///< User logged in, proceed. Logged out if appropriate
+ FileActionOk = 250, ///< Requested file action ok
+ DirectoryOk = 257, ///< PATHNAME created
+
+ // 3xx: the command has been accepted, but the requested action
+ // is dormant, pending receipt of further information
+ NeedPassword = 331, ///< User name ok, need password
+ NeedAccountToLogIn = 332, ///< Need account for login
+ NeedInformation = 350, ///< Requested file action pending further information
+
+ // 4xx: the command was not accepted and the requested action did not take place,
+ // but the error condition is temporary and the action may be requested again
+ ServiceUnavailable = 421, ///< Service not available, closing control connection
+ DataConnectionUnavailable = 425, ///< Can't open data connection
+ TransferAborted = 426, ///< Connection closed, transfer aborted
+ FileActionAborted = 450, ///< Requested file action not taken
+ LocalError = 451, ///< Requested action aborted, local error in processing
+ InsufficientStorageSpace = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable
+
+ // 5xx: the command was not accepted and
+ // the requested action did not take place
+ CommandUnknown = 500, ///< Syntax error, command unrecognized
+ ParametersUnknown = 501, ///< Syntax error in parameters or arguments
+ CommandNotImplemented = 502, ///< Command not implemented
+ BadCommandSequence = 503, ///< Bad sequence of commands
+ ParameterNotImplemented = 504, ///< Command not implemented for that parameter
+ NotLoggedIn = 530, ///< Not logged in
+ NeedAccountToStore = 532, ///< Need account for storing files
+ FileUnavailable = 550, ///< Requested action not taken, file unavailable
+ PageTypeUnknown = 551, ///< Requested action aborted, page type unknown
+ NotEnoughMemory = 552, ///< Requested file action aborted, exceeded storage allocation
+ FilenameNotAllowed = 553, ///< Requested action not taken, file name not allowed
+
+ // 10xx: SFML custom codes
+ InvalidResponse = 1000, ///< Response is not a valid FTP one
+ ConnectionFailed = 1001, ///< Connection with server failed
+ ConnectionClosed = 1002, ///< Connection with server closed
+ InvalidFile = 1003 ///< Invalid file to upload / download
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Code : Response status code (InvalidResponse by default)
+ /// \param Message : Response message (empty by default)
+ ///
+ ////////////////////////////////////////////////////////////
+ Response(Status Code = InvalidResponse, const std::string& Message = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Convenience function to check if the response status code
+ /// means a success
+ ///
+ /// \return True if status is success (code < 400)
+ ///
+ ////////////////////////////////////////////////////////////
+ bool IsOk() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the response status code
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Status GetStatus() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the full message contained in the response
+ ///
+ /// \return The response message
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetMessage() const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ Status myStatus; ///< Status code returned from the server
+ std::string myMessage; ///< Last message received from the server
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Specialization of FTP response returning a directory
+ ////////////////////////////////////////////////////////////
+ class DirectoryResponse : public Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Resp : Source response
+ ///
+ ////////////////////////////////////////////////////////////
+ DirectoryResponse(Response Resp);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the directory returned in the response
+ ///
+ /// \return Directory name
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetDirectory() const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ std::string myDirectory; ///< Directory extracted from the response message
+ };
+
+
+ ////////////////////////////////////////////////////////////
+ /// Specialization of FTP response returning a filename lisiting
+ ////////////////////////////////////////////////////////////
+ class ListingResponse : public Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Resp : Source response
+ /// \param Data : Data containing the raw listing
+ ///
+ ////////////////////////////////////////////////////////////
+ ListingResponse(Response Resp, const std::vector<char>& Data);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the number of filenames in the listing
+ ///
+ /// \return Total number of filenames
+ ///
+ ////////////////////////////////////////////////////////////
+ std::size_t GetCount() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the Index-th filename in the directory
+ ///
+ /// \param Index : Index of the filename to get
+ ///
+ /// \return Index-th filename
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetFilename(std::size_t Index) const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ std::vector<std::string> myFilenames; ///< Filenames extracted from the data
+ };
+
+
+ ////////////////////////////////////////////////////////////
+ /// Destructor -- close the connection with the server
+ ///
+ ////////////////////////////////////////////////////////////
+ ~Ftp();
+
+ ////////////////////////////////////////////////////////////
+ /// Connect to the specified FTP server
+ ///
+ /// \param Server : FTP server to connect to
+ /// \param Port : Port used for connection (21 by default, standard FTP port)
+ /// \param Timeout : Maximum time to wait, in seconds (0 by default, means no timeout)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Connect(const IPAddress& Server, unsigned short Port = 21, float Timeout = 0.f);
+
+ ////////////////////////////////////////////////////////////
+ /// Log in using anonymous account
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Login();
+
+ ////////////////////////////////////////////////////////////
+ /// Log in using a username and a password
+ ///
+ /// \param UserName : User name
+ /// \param Password : Password
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Login(const std::string& UserName, const std::string& Password);
+
+ ////////////////////////////////////////////////////////////
+ /// Close the connection with FTP server
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Disconnect();
+
+ ////////////////////////////////////////////////////////////
+ /// Send a null command just to prevent from being disconnected
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response KeepAlive();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the current working directory
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ DirectoryResponse GetWorkingDirectory();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the contents of the given directory
+ /// (subdirectories and files)
+ ///
+ /// \param Directory : Directory to list ("" by default, the current one)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ ListingResponse GetDirectoryListing(const std::string& Directory = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Change the current working directory
+ ///
+ /// \param Directory : New directory, relative to the current one
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response ChangeDirectory(const std::string& Directory);
+
+ ////////////////////////////////////////////////////////////
+ /// Go to the parent directory of the current one
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response ParentDirectory();
+
+ ////////////////////////////////////////////////////////////
+ /// Create a new directory
+ ///
+ /// \param Name : Name of the directory to create
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response MakeDirectory(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove an existing directory
+ ///
+ /// \param Name : Name of the directory to remove
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response DeleteDirectory(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Rename a file
+ ///
+ /// \param File : File to rename
+ /// \param NewName : New name
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response RenameFile(const std::string& File, const std::string& NewName);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove an existing file
+ ///
+ /// \param Name : File to remove
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response DeleteFile(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Download a file from the server
+ ///
+ /// \param DistantFile : Path of the distant file to download
+ /// \param DestPath : Where to put to file on the local computer
+ /// \param Mode : Transfer mode (binary by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Download(const std::string& DistantFile, const std::string& DestPath, TransferMode Mode = Binary);
+
+ ////////////////////////////////////////////////////////////
+ /// Upload a file to the server
+ ///
+ /// \param LocalFile : Path of the local file to upload
+ /// \param DestPath : Where to put to file on the server
+ /// \param Mode : Transfer mode (binary by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Upload(const std::string& LocalFile, const std::string& DestPath, TransferMode Mode = Binary);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ /// Send a command to the FTP server
+ ///
+ /// \param Command : Command to send
+ /// \param Parameter : Command parameter ("" by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response SendCommand(const std::string& Command, const std::string& Parameter = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Receive a response from the server
+ /// (usually after a command has been sent)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response GetResponse();
+
+ ////////////////////////////////////////////////////////////
+ /// Utility class for exchanging datas with the server
+ /// on the data channel
+ ////////////////////////////////////////////////////////////
+ class DataChannel;
+
+ friend class DataChannel;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketTCP myCommandSocket; ///< Socket holding the control connection with the server
+};
+
+} // namespace sf
+
+
+#endif // SFML_FTP_HPP
diff --git a/include/SFML/Network/.svn/text-base/Http.hpp.svn-base b/include/SFML/Network/.svn/text-base/Http.hpp.svn-base
new file mode 100644
index 0000000..3e02531
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Http.hpp.svn-base
@@ -0,0 +1,339 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_HTTP_HPP
+#define SFML_HTTP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NonCopyable.hpp>
+#include <SFML/Network/IPAddress.hpp>
+#include <SFML/Network/SocketTCP.hpp>
+#include <map>
+#include <string>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// This class provides methods for manipulating the HTTP
+/// protocol (described in RFC 1945).
+/// It can connect to a website, get its files, send requests, etc.
+////////////////////////////////////////////////////////////
+class SFML_API Http : NonCopyable
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps an HTTP request, which is basically :
+ /// - a header with a method, a target URI, and a set of field/value pairs
+ /// - an optional body (for POST requests)
+ ////////////////////////////////////////////////////////////
+ class SFML_API Request
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate the available HTTP methods for a request
+ ////////////////////////////////////////////////////////////
+ enum Method
+ {
+ Get, ///< Request in get mode, standard method to retrieve a page
+ Post, ///< Request in post mode, usually to send data to a page
+ Head ///< Request a page's header only
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param RequestMethod : Method to use for the request (Get by default)
+ /// \param URI : Target URI ("/" by default -- index page)
+ /// \param Body : Content of the request's body (empty by default)
+ ///
+ ////////////////////////////////////////////////////////////
+ Request(Method RequestMethod = Get, const std::string& URI = "/", const std::string& Body = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Set the value of a field; the field is added if it doesn't exist
+ ///
+ /// \param Field : Name of the field to set (case-insensitive)
+ /// \param Value : Value of the field
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetField(const std::string& Field, const std::string& Value);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the request method.
+ /// This parameter is Http::Request::Get by default
+ ///
+ /// \param RequestMethod : Method to use for the request
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetMethod(Method RequestMethod);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the target URI of the request.
+ /// This parameter is "/" by default
+ ///
+ /// \param URI : URI to request, local to the host
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetURI(const std::string& URI);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the HTTP version of the request.
+ /// This parameter is 1.0 by default
+ ///
+ /// \param Major : Major version number
+ /// \param Minor : Minor version number
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetHttpVersion(unsigned int Major, unsigned int Minor);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the body of the request. This parameter is optional and
+ /// makes sense only for POST requests.
+ /// This parameter is empty by default
+ ///
+ /// \param Body : Content of the request body
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetBody(const std::string& Body);
+
+ private :
+
+ friend class Http;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the string representation of the request header
+ ///
+ /// \return String containing the request
+ ///
+ ////////////////////////////////////////////////////////////
+ std::string ToString() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Check if the given field has been defined
+ ///
+ /// \param Field : Name of the field to check (case-insensitive)
+ ///
+ /// \return True if the field exists
+ ///
+ ////////////////////////////////////////////////////////////
+ bool HasField(const std::string& Field) const;
+
+ ////////////////////////////////////////////////////////////
+ // Types
+ ////////////////////////////////////////////////////////////
+ typedef std::map<std::string, std::string> FieldTable;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ FieldTable myFields; ///< Fields of the header
+ Method myMethod; ///< Method to use for the request
+ std::string myURI; ///< Target URI of the request
+ unsigned int myMajorVersion; ///< Major HTTP version
+ unsigned int myMinorVersion; ///< Minor HTTP version
+ std::string myBody; ///< Body of the request
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps an HTTP response, which is basically :
+ /// - a header with a status code and a set of field/value pairs
+ /// - a body (the content of the requested resource)
+ ////////////////////////////////////////////////////////////
+ class SFML_API Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate all the valid status codes returned in
+ /// a HTTP response
+ ////////////////////////////////////////////////////////////
+ enum Status
+ {
+ // 2xx: success
+ Ok = 200, ///< Most common code returned when operation was successful
+ Created = 201, ///< The resource has successfully been created
+ Accepted = 202, ///< The request has been accepted, but will be processed later by the server
+ NoContent = 204, ///< Sent when the server didn't send any data in return
+
+ // 3xx: redirection
+ MultipleChoices = 300, ///< The requested page can be accessed from several locations
+ MovedPermanently = 301, ///< The requested page has permanently moved to a new location
+ MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
+ NotModified = 304, ///< For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed
+
+ // 4xx: client error
+ BadRequest = 400, ///< The server couldn't understand the request (syntax error)
+ Unauthorized = 401, ///< The requested page needs an authentification to be accessed
+ Forbidden = 403, ///< The requested page cannot be accessed at all, even with authentification
+ NotFound = 404, ///< The requested page doesn't exist
+
+ // 5xx: server error
+ InternalServerError = 500, ///< The server encountered an unexpected error
+ NotImplemented = 501, ///< The server doesn't implement a requested feature
+ BadGateway = 502, ///< The gateway server has received an error from the source server
+ ServiceNotAvailable = 503, ///< The server is temporarily unavailable (overloaded, in maintenance, ...)
+
+ // 10xx: SFML custom codes
+ InvalidResponse = 1000, ///< Response is not a valid HTTP one
+ ConnectionFailed = 1001 ///< Connection with server failed
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ Response();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the value of a field
+ ///
+ /// \param Field : Name of the field to get (case-insensitive)
+ ///
+ /// \return Value of the field, or empty string if not found
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetField(const std::string& Field) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the header's status code
+ ///
+ /// \return Header's status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Status GetStatus() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the major HTTP version number of the response
+ ///
+ /// \return Major version number
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int GetMajorHttpVersion() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the major HTTP version number of the response
+ ///
+ /// \return Major version number
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int GetMinorHttpVersion() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the body of the response. The body can contain :
+ /// - the requested page (for GET requests)
+ /// - a response from the server (for POST requests)
+ /// - nothing (for HEAD requests)
+ /// - an error message (in case of an error)
+ ///
+ /// \return The response body
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetBody() const;
+
+ private :
+
+ friend class Http;
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the header from a response string
+ ///
+ /// \param Data : Content of the response's header to parse
+ ///
+ ////////////////////////////////////////////////////////////
+ void FromString(const std::string& Data);
+
+ ////////////////////////////////////////////////////////////
+ // Types
+ ////////////////////////////////////////////////////////////
+ typedef std::map<std::string, std::string> FieldTable;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ FieldTable myFields; ///< Fields of the header
+ Status myStatus; ///< Status code
+ unsigned int myMajorVersion; ///< Major HTTP version
+ unsigned int myMinorVersion; ///< Minor HTTP version
+ std::string myBody; ///< Body of the response
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ Http();
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the Http instance with the target host
+ ///
+ /// \param Host : Web server to connect to
+ /// \param Port : Port to use for connection (0 by default -- use the standard port of the protocol used)
+ ///
+ ////////////////////////////////////////////////////////////
+ Http(const std::string& Host, unsigned short Port = 0);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the target host
+ ///
+ /// \param Host : Web server to connect to
+ /// \param Port : Port to use for connection (0 by default -- use the standard port of the protocol used)
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetHost(const std::string& Host, unsigned short Port = 0);
+
+ ////////////////////////////////////////////////////////////
+ /// Send a HTTP request and return the server's response.
+ /// You must be connected to a host before sending requests.
+ /// Any missing mandatory header field will be added with an appropriate value.
+ /// Warning : this function waits for the server's response and may
+ /// not return instantly; use a thread if you don't want to block your
+ /// application.
+ ///
+ /// \param Req : Request to send
+ ///
+ /// \return Server's response
+ ///
+ ////////////////////////////////////////////////////////////
+ Response SendRequest(const Request& Req);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketTCP myConnection; ///< Connection to the host
+ IPAddress myHost; ///< Web host address
+ std::string myHostName; ///< Web host name
+ unsigned short myPort; ///< Port used for connection with host
+};
+
+} // namespace sf
+
+
+#endif // SFML_HTTP_HPP
diff --git a/include/SFML/Network/.svn/text-base/IPAddress.hpp.svn-base b/include/SFML/Network/.svn/text-base/IPAddress.hpp.svn-base
new file mode 100644
index 0000000..8373315
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/IPAddress.hpp.svn-base
@@ -0,0 +1,229 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_IPADDRESS_HPP
+#define SFML_IPADDRESS_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+#include <istream>
+#include <ostream>
+#include <string>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// IPAddress provides easy manipulation of IP v4 addresses
+////////////////////////////////////////////////////////////
+class SFML_API IPAddress
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor -- constructs an invalid address
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress();
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the address from a string
+ ///
+ /// \param Address : IP address ("xxx.xxx.xxx.xxx") or network name
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress(const std::string& Address);
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the address from a C-style string ;
+ /// Needed for implicit conversions from literal strings to IPAddress to work
+ ///
+ /// \param Address : IP address ("xxx.xxx.xxx.xxx") or network name
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress(const char* Address);
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the address from 4 bytes
+ ///
+ /// \param Byte0 : First byte of the address
+ /// \param Byte1 : Second byte of the address
+ /// \param Byte2 : Third byte of the address
+ /// \param Byte3 : Fourth byte of the address
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress(Uint8 Byte0, Uint8 Byte1, Uint8 Byte2, Uint8 Byte3);
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the address from a 32-bits integer
+ ///
+ /// \param Address : 4 bytes of the address packed into a 32-bits integer
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress(Uint32 Address);
+
+ ////////////////////////////////////////////////////////////
+ /// Tell if the address is a valid one
+ ///
+ /// \return True if address has a valid syntax
+ ///
+ ////////////////////////////////////////////////////////////
+ bool IsValid() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get a string representation of the address
+ ///
+ /// \return String representation of the IP address ("xxx.xxx.xxx.xxx")
+ ///
+ ////////////////////////////////////////////////////////////
+ std::string ToString() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get an integer representation of the address
+ ///
+ /// \return 32-bits integer containing the 4 bytes of the address, in system endianness
+ ///
+ ////////////////////////////////////////////////////////////
+ Uint32 ToInteger() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the computer's local IP address (from the LAN point of view)
+ ///
+ /// \return Local IP address
+ ///
+ ////////////////////////////////////////////////////////////
+ static IPAddress GetLocalAddress();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the computer's public IP address (from the web point of view).
+ /// The only way to get a public address is to ask it to a
+ /// distant website ; as a consequence, this function may be
+ /// very slow -- use it as few as possible !
+ ///
+ /// \return Public IP address
+ ///
+ ////////////////////////////////////////////////////////////
+ static IPAddress GetPublicAddress();
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator ==
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this == Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator ==(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator !=
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this != Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator !=(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator <
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this < Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator <(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator >
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this > Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator >(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator <=
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this <= Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator <=(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator >=
+ ///
+ /// \param Other : Address to compare
+ ///
+ /// \return True if *this >= Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator >=(const IPAddress& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ // Static member data
+ ////////////////////////////////////////////////////////////
+ static const IPAddress LocalHost; ///< Local host address (to connect to the same computer)
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ Uint32 myAddress; ///< Address stored as an unsigned 32 bits integer
+};
+
+////////////////////////////////////////////////////////////
+/// Operator >> overload to extract an address from an input stream
+///
+/// \param Stream : Input stream
+/// \param Address : Address to extract
+///
+/// \return Reference to the input stream
+///
+////////////////////////////////////////////////////////////
+SFML_API std::istream& operator >>(std::istream& Stream, IPAddress& Address);
+
+////////////////////////////////////////////////////////////
+/// Operator << overload to print an address to an output stream
+///
+/// \param Stream : Output stream
+/// \param Address : Address to print
+///
+/// \return Reference to the output stream
+///
+////////////////////////////////////////////////////////////
+SFML_API std::ostream& operator <<(std::ostream& Stream, const IPAddress& Address);
+
+} // namespace sf
+
+
+#endif // SFML_IPADDRESS_HPP
diff --git a/include/SFML/Network/.svn/text-base/Packet.hpp.svn-base b/include/SFML/Network/.svn/text-base/Packet.hpp.svn-base
new file mode 100644
index 0000000..3add17f
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Packet.hpp.svn-base
@@ -0,0 +1,187 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_PACKET_HPP
+#define SFML_PACKET_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+#include <string>
+#include <vector>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Packet wraps data to send / to receive through the network
+////////////////////////////////////////////////////////////
+class SFML_API Packet
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ Packet();
+
+ ////////////////////////////////////////////////////////////
+ /// Virtual destructor
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual ~Packet();
+
+ ////////////////////////////////////////////////////////////
+ /// Append data to the end of the packet
+ ///
+ /// \param Data : Pointer to the bytes to append
+ /// \param SizeInBytes : Number of bytes to append
+ ///
+ ////////////////////////////////////////////////////////////
+ void Append(const void* Data, std::size_t SizeInBytes);
+
+ ////////////////////////////////////////////////////////////
+ /// Clear the packet data
+ ///
+ ////////////////////////////////////////////////////////////
+ void Clear();
+
+ ////////////////////////////////////////////////////////////
+ /// Get a pointer to the data contained in the packet
+ /// Warning : the returned pointer may be invalid after you
+ /// append data to the packet
+ ///
+ /// \return Pointer to the data
+ ///
+ ////////////////////////////////////////////////////////////
+ const char* GetData() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the size of the data contained in the packet
+ ///
+ /// \return Data size, in bytes
+ ///
+ ////////////////////////////////////////////////////////////
+ std::size_t GetDataSize() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Tell if the reading position has reached the end of the packet
+ ///
+ /// \return True if all data have been read into the packet
+ ///
+ ////////////////////////////////////////////////////////////
+ bool EndOfPacket() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Return the validity of packet
+ ///
+ /// \return True if last data extraction from packet was successful
+ ///
+ ////////////////////////////////////////////////////////////
+ operator bool() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Operator >> overloads to extract data from the packet
+ ///
+ ////////////////////////////////////////////////////////////
+ Packet& operator >>(bool& Data);
+ Packet& operator >>(Int8& Data);
+ Packet& operator >>(Uint8& Data);
+ Packet& operator >>(Int16& Data);
+ Packet& operator >>(Uint16& Data);
+ Packet& operator >>(Int32& Data);
+ Packet& operator >>(Uint32& Data);
+ Packet& operator >>(float& Data);
+ Packet& operator >>(double& Data);
+ Packet& operator >>(char* Data);
+ Packet& operator >>(std::string& Data);
+ Packet& operator >>(wchar_t* Data);
+ Packet& operator >>(std::wstring& Data);
+
+ ////////////////////////////////////////////////////////////
+ /// Operator << overloads to put data into the packet
+ ///
+ ////////////////////////////////////////////////////////////
+ Packet& operator <<(bool Data);
+ Packet& operator <<(Int8 Data);
+ Packet& operator <<(Uint8 Data);
+ Packet& operator <<(Int16 Data);
+ Packet& operator <<(Uint16 Data);
+ Packet& operator <<(Int32 Data);
+ Packet& operator <<(Uint32 Data);
+ Packet& operator <<(float Data);
+ Packet& operator <<(double Data);
+ Packet& operator <<(const char* Data);
+ Packet& operator <<(const std::string& Data);
+ Packet& operator <<(const wchar_t* Data);
+ Packet& operator <<(const std::wstring& Data);
+
+private :
+
+ friend class SocketTCP;
+ friend class SocketUDP;
+
+ ////////////////////////////////////////////////////////////
+ /// Check if the packet can extract a given size of bytes
+ ///
+ /// \param Size : Size to check
+ ///
+ /// \return True if Size bytes can be read from the packet's data
+ ///
+ ////////////////////////////////////////////////////////////
+ bool CheckSize(std::size_t Size);
+
+ ////////////////////////////////////////////////////////////
+ /// Called before the packet is sent to the network
+ ///
+ /// \param DataSize : Variable to fill with the size of data to send
+ ///
+ /// \return Pointer to the array of bytes to send
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual const char* OnSend(std::size_t& DataSize);
+
+ ////////////////////////////////////////////////////////////
+ /// Called after the packet has been received from the network
+ ///
+ /// \param Data : Pointer to the array of received bytes
+ /// \param DataSize : Size of the array of bytes
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void OnReceive(const char* Data, std::size_t DataSize);
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ std::vector<char> myData; ///< Data stored in the packet
+ std::size_t myReadPos; ///< Current reading position in the packet
+ bool myIsValid; ///< Reading state of the packet
+};
+
+} // namespace sf
+
+
+#endif // SFML_PACKET_HPP
diff --git a/include/SFML/Network/.svn/text-base/Selector.hpp.svn-base b/include/SFML/Network/.svn/text-base/Selector.hpp.svn-base
new file mode 100644
index 0000000..3ab7dfa
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Selector.hpp.svn-base
@@ -0,0 +1,116 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SELECTOR_HPP
+#define SFML_SELECTOR_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Network/SocketUDP.hpp>
+#include <SFML/Network/SocketTCP.hpp>
+#include <SFML/Network/SelectorBase.hpp>
+#include <map>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Selector allow reading from multiple sockets
+/// without blocking. It's a kind of multiplexer
+////////////////////////////////////////////////////////////
+template <typename Type>
+class Selector : private SelectorBase
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Add a socket to watch
+ ///
+ /// \param Socket : Socket to add
+ ///
+ ////////////////////////////////////////////////////////////
+ void Add(Type Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove a socket
+ ///
+ /// \param Socket : Socket to remove
+ ///
+ ////////////////////////////////////////////////////////////
+ void Remove(Type Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove all sockets
+ ///
+ ////////////////////////////////////////////////////////////
+ void Clear();
+
+ ////////////////////////////////////////////////////////////
+ /// Wait and collect sockets which are ready for reading.
+ /// This functions will return either when at least one socket
+ /// is ready, or when the given time is out
+ ///
+ /// \param Timeout : Timeout, in seconds (0 by default : no timeout)
+ ///
+ /// \return Number of sockets ready to be read
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int Wait(float Timeout = 0.f);
+
+ ////////////////////////////////////////////////////////////
+ /// After a call to Wait(), get the Index-th socket which is
+ /// ready for reading. The total number of sockets ready
+ /// is the integer returned by the previous call to Wait()
+ ///
+ /// \param Index : Index of the socket to get
+ ///
+ /// \return The Index-th socket
+ ///
+ ////////////////////////////////////////////////////////////
+ Type GetSocketReady(unsigned int Index);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ // Types
+ ////////////////////////////////////////////////////////////
+ typedef std::map<SocketHelper::SocketType, Type> SocketTable;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketTable mySockets; ///< Table matching the SFML socket instances with their low-level handles
+};
+
+#include <SFML/Network/Selector.inl>
+
+// Let's define the two only valid types of Selector
+typedef Selector<SocketUDP> SelectorUDP;
+typedef Selector<SocketTCP> SelectorTCP;
+
+} // namespace sf
+
+
+#endif // SFML_SELECTOR_HPP
diff --git a/include/SFML/Network/.svn/text-base/Selector.inl.svn-base b/include/SFML/Network/.svn/text-base/Selector.inl.svn-base
new file mode 100644
index 0000000..326c994
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Selector.inl.svn-base
@@ -0,0 +1,97 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////
+/// Add a socket to watch
+////////////////////////////////////////////////////////////
+template <typename Type>
+void Selector<Type>::Add(Type Socket)
+{
+ if (Socket.IsValid())
+ {
+ SelectorBase::Add(Socket.mySocket);
+ mySockets[Socket.mySocket] = Socket;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Remove a socket
+////////////////////////////////////////////////////////////
+template <typename Type>
+void Selector<Type>::Remove(Type Socket)
+{
+ typename SocketTable::iterator It = mySockets.find(Socket.mySocket);
+ if (It != mySockets.end())
+ {
+ SelectorBase::Remove(Socket.mySocket);
+ mySockets.erase(It);
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+/// Remove all sockets
+////////////////////////////////////////////////////////////
+template <typename Type>
+void Selector<Type>::Clear()
+{
+ SelectorBase::Clear();
+ mySockets.clear();
+}
+
+
+////////////////////////////////////////////////////////////
+/// Wait and collect sockets which are ready for reading.
+/// This functions will return either when at least one socket
+/// is ready, or when the given time is out
+////////////////////////////////////////////////////////////
+template <typename Type>
+unsigned int Selector<Type>::Wait(float Timeout)
+{
+ // No socket in the selector : return 0
+ if (mySockets.empty())
+ return 0;
+
+ return SelectorBase::Wait(Timeout);
+}
+
+
+////////////////////////////////////////////////////////////
+/// After a call to Wait(), get the Index-th socket which is
+/// ready for reading. The total number of sockets ready
+/// is the integer returned by the previous call to Wait()
+////////////////////////////////////////////////////////////
+template <typename Type>
+Type Selector<Type>::GetSocketReady(unsigned int Index)
+{
+ SocketHelper::SocketType Socket = SelectorBase::GetSocketReady(Index);
+
+ typename SocketTable::const_iterator It = mySockets.find(Socket);
+ if (It != mySockets.end())
+ return It->second;
+ else
+ return Type(Socket);
+}
diff --git a/include/SFML/Network/.svn/text-base/SelectorBase.hpp.svn-base b/include/SFML/Network/.svn/text-base/SelectorBase.hpp.svn-base
new file mode 100644
index 0000000..433e789
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/SelectorBase.hpp.svn-base
@@ -0,0 +1,112 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SELECTORBASE_HPP
+#define SFML_SELECTORBASE_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+#include <SFML/Network/SocketHelper.hpp>
+#include <map>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// Private base class for selectors.
+/// As Selector is a template class, this base is needed so that
+/// every system call get compiled in SFML (not inlined)
+////////////////////////////////////////////////////////////
+class SFML_API SelectorBase
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ SelectorBase();
+
+ ////////////////////////////////////////////////////////////
+ /// Add a socket to watch
+ ///
+ /// \param Socket : Socket to add
+ ///
+ ////////////////////////////////////////////////////////////
+ void Add(SocketHelper::SocketType Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove a socket
+ ///
+ /// \param Socket : Socket to remove
+ ///
+ ////////////////////////////////////////////////////////////
+ void Remove(SocketHelper::SocketType Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove all sockets
+ ///
+ ////////////////////////////////////////////////////////////
+ void Clear();
+
+ ////////////////////////////////////////////////////////////
+ /// Wait and collect sockets which are ready for reading.
+ /// This functions will return either when at least one socket
+ /// is ready, or when the given time is out
+ ///
+ /// \param Timeout : Timeout, in seconds (0 by default : no timeout)
+ ///
+ /// \return Number of sockets ready to be read
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int Wait(float Timeout = 0.f);
+
+ ////////////////////////////////////////////////////////////
+ /// After a call to Wait(), get the Index-th socket which is
+ /// ready for reading. The total number of sockets ready
+ /// is the integer returned by the previous call to Wait()
+ ///
+ /// \param Index : Index of the socket to get
+ ///
+ /// \return The Index-th socket
+ ///
+ ////////////////////////////////////////////////////////////
+ SocketHelper::SocketType GetSocketReady(unsigned int Index);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ fd_set mySet; ///< Set of socket to watch
+ fd_set mySetReady; ///< Set of socket which are ready for reading
+ int myMaxSocket; ///< Maximum socket index
+};
+
+} // namespace sf
+
+
+#endif // SFML_SELECTORBASE_HPP
diff --git a/include/SFML/Network/.svn/text-base/SocketHelper.hpp.svn-base b/include/SFML/Network/.svn/text-base/SocketHelper.hpp.svn-base
new file mode 100644
index 0000000..36126db
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/SocketHelper.hpp.svn-base
@@ -0,0 +1,64 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETHELPER_HPP
+#define SFML_SOCKETHELPER_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+
+
+namespace sf
+{
+namespace Socket
+{
+ ////////////////////////////////////////////////////////////
+ /// Enumeration of status returned by socket functions
+ ////////////////////////////////////////////////////////////
+ enum Status
+ {
+ Done, ///< The socket has sent / received the data
+ NotReady, ///< The socket is not ready to send / receive data yet
+ Disconnected, ///< The TCP socket has been disconnected
+ Error ///< An unexpected error happened
+ };
+}
+
+} // namespace sf
+
+
+#ifdef SFML_SYSTEM_WINDOWS
+
+ #include <SFML/Network/Win32/SocketHelper.hpp>
+
+#else
+
+ #include <SFML/Network/Unix/SocketHelper.hpp>
+
+#endif
+
+
+#endif // SFML_SOCKETHELPER_HPP
diff --git a/include/SFML/Network/.svn/text-base/SocketTCP.hpp.svn-base b/include/SFML/Network/.svn/text-base/SocketTCP.hpp.svn-base
new file mode 100644
index 0000000..452b304
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/SocketTCP.hpp.svn-base
@@ -0,0 +1,225 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETTCP_HPP
+#define SFML_SOCKETTCP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Network/SocketHelper.hpp>
+#include <vector>
+
+
+namespace sf
+{
+class Packet;
+class IPAddress;
+template <typename> class Selector;
+
+////////////////////////////////////////////////////////////
+/// SocketTCP wraps a socket using TCP protocol to
+/// send data safely (but a bit slower)
+////////////////////////////////////////////////////////////
+class SFML_API SocketTCP
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ SocketTCP();
+
+ ////////////////////////////////////////////////////////////
+ /// Change the blocking state of the socket.
+ /// The default behaviour of a socket is blocking
+ ///
+ /// \param Blocking : Pass true to set the socket as blocking, or false for non-blocking
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetBlocking(bool Blocking);
+
+ ////////////////////////////////////////////////////////////
+ /// Connect to another computer on a specified port
+ ///
+ /// \param Port : Port to use for transfers (warning : ports < 1024 are reserved)
+ /// \param HostAddress : IP Address of the host to connect to
+ /// \param Timeout : Maximum time to wait, in seconds (0 by default : no timeout) (this parameter is ignored for non-blocking sockets)
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Connect(unsigned short Port, const IPAddress& HostAddress, float Timeout = 0.f);
+
+ ////////////////////////////////////////////////////////////
+ /// Listen to a specified port for incoming data or connections
+ ///
+ /// \param Port : Port to listen to
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool Listen(unsigned short Port);
+
+ ////////////////////////////////////////////////////////////
+ /// Wait for a connection (must be listening to a port).
+ /// This function will block if the socket is blocking
+ ///
+ /// \param Connected : Socket containing the connection with the connected client
+ /// \param Address : Pointer to an address to fill with client infos (NULL by default)
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Accept(SocketTCP& Connected, IPAddress* Address = NULL);
+
+ ////////////////////////////////////////////////////////////
+ /// Send an array of bytes to the host (must be connected first)
+ ///
+ /// \param Data : Pointer to the bytes to send
+ /// \param Size : Number of bytes to send
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Send(const char* Data, std::size_t Size);
+
+ ////////////////////////////////////////////////////////////
+ /// Receive an array of bytes from the host (must be connected first).
+ /// This function will block if the socket is blocking
+ ///
+ /// \param Data : Pointer to a byte array to fill (make sure it is big enough)
+ /// \param MaxSize : Maximum number of bytes to read
+ /// \param SizeReceived : Number of bytes received
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Receive(char* Data, std::size_t MaxSize, std::size_t& SizeReceived);
+
+ ////////////////////////////////////////////////////////////
+ /// Send a packet of data to the host (must be connected first)
+ ///
+ /// \param PacketToSend : Packet to send
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Send(Packet& PacketToSend);
+
+ ////////////////////////////////////////////////////////////
+ /// Receive a packet from the host (must be connected first).
+ /// This function will block if the socket is blocking
+ ///
+ /// \param PacketToReceive : Packet to fill with received data
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Receive(Packet& PacketToReceive);
+
+ ////////////////////////////////////////////////////////////
+ /// Close the socket
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool Close();
+
+ ////////////////////////////////////////////////////////////
+ /// Check if the socket is in a valid state ; this function
+ /// can be called any time to check if the socket is OK
+ ///
+ /// \return True if the socket is valid
+ ///
+ ////////////////////////////////////////////////////////////
+ bool IsValid() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator ==
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this == Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator ==(const SocketTCP& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator !=
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this != Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator !=(const SocketTCP& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator <.
+ /// Provided for compatibility with standard containers, as
+ /// comparing two sockets doesn't make much sense...
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this < Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator <(const SocketTCP& Other) const;
+
+private :
+
+ friend class Selector<SocketTCP>;
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the socket from a socket descriptor
+ /// (for internal use only)
+ ///
+ /// \param Descriptor : Socket descriptor
+ ///
+ ////////////////////////////////////////////////////////////
+ SocketTCP(SocketHelper::SocketType Descriptor);
+
+ ////////////////////////////////////////////////////////////
+ /// Create the socket
+ ///
+ /// \param Descriptor : System socket descriptor to use (0 by default -- create a new socket)
+ ///
+ ////////////////////////////////////////////////////////////
+ void Create(SocketHelper::SocketType Descriptor = 0);
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketHelper::SocketType mySocket; ///< Socket descriptor
+ std::vector<char> myPendingPacket; ///< Data of the current pending packet, if any (in non-blocking mode)
+ Int32 myPendingPacketSize; ///< Size of the current pending packet, if any (in non-blocking mode)
+ bool myIsBlocking; ///< Is the socket blocking or non-blocking ?
+};
+
+} // namespace sf
+
+
+#endif // SFML_SOCKETTCP_HPP
diff --git a/include/SFML/Network/.svn/text-base/SocketUDP.hpp.svn-base b/include/SFML/Network/.svn/text-base/SocketUDP.hpp.svn-base
new file mode 100644
index 0000000..ba43762
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/SocketUDP.hpp.svn-base
@@ -0,0 +1,224 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETUDP_HPP
+#define SFML_SOCKETUDP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Network/SocketHelper.hpp>
+#include <vector>
+
+
+namespace sf
+{
+class Packet;
+class IPAddress;
+template <typename> class Selector;
+
+////////////////////////////////////////////////////////////
+/// SocketUDP wraps a socket using UDP protocol to
+/// send data fastly (but with less safety)
+////////////////////////////////////////////////////////////
+class SFML_API SocketUDP
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ SocketUDP();
+
+ ////////////////////////////////////////////////////////////
+ /// Change the blocking state of the socket.
+ /// The default behaviour of a socket is blocking
+ ///
+ /// \param Blocking : Pass true to set the socket as blocking, or false for non-blocking
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetBlocking(bool Blocking);
+
+ ////////////////////////////////////////////////////////////
+ /// Bind the socket to a specific port
+ ///
+ /// \param Port : Port to bind the socket to
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool Bind(unsigned short Port);
+
+ ////////////////////////////////////////////////////////////
+ /// Unbind the socket from its previous port, if any
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool Unbind();
+
+ ////////////////////////////////////////////////////////////
+ /// Send an array of bytes
+ ///
+ /// \param Data : Pointer to the bytes to send
+ /// \param Size : Number of bytes to send
+ /// \param Address : Address of the computer to send the packet to
+ /// \param Port : Port to send the data to
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Send(const char* Data, std::size_t Size, const IPAddress& Address, unsigned short Port);
+
+ ////////////////////////////////////////////////////////////
+ /// Receive an array of bytes.
+ /// This function will block if the socket is blocking
+ ///
+ /// \param Data : Pointer to a byte array to fill (make sure it is big enough)
+ /// \param MaxSize : Maximum number of bytes to read
+ /// \param SizeReceived : Number of bytes received
+ /// \param Address : Address of the computer which sent the data
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Receive(char* Data, std::size_t MaxSize, std::size_t& SizeReceived, IPAddress& Address);
+
+ ////////////////////////////////////////////////////////////
+ /// Send a packet of data
+ ///
+ /// \param PacketToSend : Packet to send
+ /// \param Address : Address of the computer to send the packet to
+ /// \param Port : Port to send the data to
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Send(Packet& PacketToSend, const IPAddress& Address, unsigned short Port);
+
+ ////////////////////////////////////////////////////////////
+ /// Receive a packet.
+ /// This function will block if the socket is blocking
+ ///
+ /// \param PacketToReceive : Packet to fill with received data
+ /// \param Address : Address of the computer which sent the packet
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Socket::Status Receive(Packet& PacketToReceive, IPAddress& Address);
+
+ ////////////////////////////////////////////////////////////
+ /// Close the socket
+ ///
+ /// \return True if operation has been successful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool Close();
+
+ ////////////////////////////////////////////////////////////
+ /// Check if the socket is in a valid state ; this function
+ /// can be called any time to check if the socket is OK
+ ///
+ /// \return True if the socket is valid
+ ///
+ ////////////////////////////////////////////////////////////
+ bool IsValid() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the port the socket is currently bound to
+ ///
+ /// \return Current port (0 means the socket is not bound)
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned short GetPort() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator ==
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this == Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator ==(const SocketUDP& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator !=
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this != Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator !=(const SocketUDP& Other) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Comparison operator <.
+ /// Provided for compatibility with standard containers, as
+ /// comparing two sockets doesn't make much sense...
+ ///
+ /// \param Other : Socket to compare
+ ///
+ /// \return True if *this < Other
+ ///
+ ////////////////////////////////////////////////////////////
+ bool operator <(const SocketUDP& Other) const;
+
+private :
+
+ friend class Selector<SocketUDP>;
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the socket from a socket descriptor
+ /// (for internal use only)
+ ///
+ /// \param Descriptor : Socket descriptor
+ ///
+ ////////////////////////////////////////////////////////////
+ SocketUDP(SocketHelper::SocketType Descriptor);
+
+ ////////////////////////////////////////////////////////////
+ /// Create the socket
+ ///
+ /// \param Descriptor : System socket descriptor to use (0 by default -- create a new socket)
+ ///
+ ////////////////////////////////////////////////////////////
+ void Create(SocketHelper::SocketType Descriptor = 0);
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketHelper::SocketType mySocket; ///< Socket identifier
+ unsigned short myPort; ///< Port to which the socket is bound
+ std::vector<char> myPendingPacket; ///< Data of the current pending packet, if any (in non-blocking mode)
+ Int32 myPendingPacketSize; ///< Size of the current pending packet, if any (in non-blocking mode)
+ bool myIsBlocking; ///< Is the socket blocking or non-blocking ?
+};
+
+} // namespace sf
+
+
+#endif // SFML_SOCKETUDP_HPP
diff --git a/include/SFML/Network/.svn/text-base/Sockets.hpp.svn-base b/include/SFML/Network/.svn/text-base/Sockets.hpp.svn-base
new file mode 100644
index 0000000..b611e85
--- /dev/null
+++ b/include/SFML/Network/.svn/text-base/Sockets.hpp.svn-base
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETS_HPP
+#define SFML_SOCKETS_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+
+
+#ifdef SFML_SYSTEM_WINDOWS
+
+ #include <SFML/Network/Win32/Sockets.hpp>
+
+#else
+
+ #include <SFML/Network/Unix/Sockets.hpp>
+
+#endif
+
+
+#endif // SFML_SOCKETS_HPP
diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp
new file mode 100644
index 0000000..d4bb439
--- /dev/null
+++ b/include/SFML/Network/Ftp.hpp
@@ -0,0 +1,448 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_FTP_HPP
+#define SFML_FTP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NonCopyable.hpp>
+#include <SFML/Network/SocketTCP.hpp>
+#include <string>
+#include <vector>
+
+
+namespace sf
+{
+class IPAddress;
+
+////////////////////////////////////////////////////////////
+/// This class provides methods for manipulating the FTP
+/// protocol (described in RFC 959).
+/// It provides easy access and transfers to remote
+/// directories and files on a FTP server
+////////////////////////////////////////////////////////////
+class SFML_API Ftp : NonCopyable
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumeration of transfer modes
+ ////////////////////////////////////////////////////////////
+ enum TransferMode
+ {
+ Binary, ///< Binary mode (file is transfered as a sequence of bytes)
+ Ascii, ///< Text mode using ASCII encoding
+ Ebcdic ///< Text mode using EBCDIC encoding
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps a FTP response, which is basically :
+ /// - a status code
+ /// - a message
+ ////////////////////////////////////////////////////////////
+ class Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate all the valid status codes returned in
+ /// a FTP response
+ ////////////////////////////////////////////////////////////
+ enum Status
+ {
+ // 1xx: the requested action is being initiated,
+ // expect another reply before proceeding with a new command
+ RestartMarkerReply = 110, ///< Restart marker reply
+ ServiceReadySoon = 120, ///< Service ready in N minutes
+ DataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting
+ OpeningDataConnection = 150, ///< File status ok, about to open data connection
+
+ // 2xx: the requested action has been successfully completed
+ Ok = 200, ///< Command ok
+ PointlessCommand = 202, ///< Command not implemented
+ SystemStatus = 211, ///< System status, or system help reply
+ DirectoryStatus = 212, ///< Directory status
+ FileStatus = 213, ///< File status
+ HelpMessage = 214, ///< Help message
+ SystemType = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document
+ ServiceReady = 220, ///< Service ready for new user
+ ClosingConnection = 221, ///< Service closing control connection
+ DataConnectionOpened = 225, ///< Data connection open, no transfer in progress
+ ClosingDataConnection = 226, ///< Closing data connection, requested file action successful
+ EnteringPassiveMode = 227, ///< Entering passive mode
+ LoggedIn = 230, ///< User logged in, proceed. Logged out if appropriate
+ FileActionOk = 250, ///< Requested file action ok
+ DirectoryOk = 257, ///< PATHNAME created
+
+ // 3xx: the command has been accepted, but the requested action
+ // is dormant, pending receipt of further information
+ NeedPassword = 331, ///< User name ok, need password
+ NeedAccountToLogIn = 332, ///< Need account for login
+ NeedInformation = 350, ///< Requested file action pending further information
+
+ // 4xx: the command was not accepted and the requested action did not take place,
+ // but the error condition is temporary and the action may be requested again
+ ServiceUnavailable = 421, ///< Service not available, closing control connection
+ DataConnectionUnavailable = 425, ///< Can't open data connection
+ TransferAborted = 426, ///< Connection closed, transfer aborted
+ FileActionAborted = 450, ///< Requested file action not taken
+ LocalError = 451, ///< Requested action aborted, local error in processing
+ InsufficientStorageSpace = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable
+
+ // 5xx: the command was not accepted and
+ // the requested action did not take place
+ CommandUnknown = 500, ///< Syntax error, command unrecognized
+ ParametersUnknown = 501, ///< Syntax error in parameters or arguments
+ CommandNotImplemented = 502, ///< Command not implemented
+ BadCommandSequence = 503, ///< Bad sequence of commands
+ ParameterNotImplemented = 504, ///< Command not implemented for that parameter
+ NotLoggedIn = 530, ///< Not logged in
+ NeedAccountToStore = 532, ///< Need account for storing files
+ FileUnavailable = 550, ///< Requested action not taken, file unavailable
+ PageTypeUnknown = 551, ///< Requested action aborted, page type unknown
+ NotEnoughMemory = 552, ///< Requested file action aborted, exceeded storage allocation
+ FilenameNotAllowed = 553, ///< Requested action not taken, file name not allowed
+
+ // 10xx: SFML custom codes
+ InvalidResponse = 1000, ///< Response is not a valid FTP one
+ ConnectionFailed = 1001, ///< Connection with server failed
+ ConnectionClosed = 1002, ///< Connection with server closed
+ InvalidFile = 1003 ///< Invalid file to upload / download
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Code : Response status code (InvalidResponse by default)
+ /// \param Message : Response message (empty by default)
+ ///
+ ////////////////////////////////////////////////////////////
+ Response(Status Code = InvalidResponse, const std::string& Message = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Convenience function to check if the response status code
+ /// means a success
+ ///
+ /// \return True if status is success (code < 400)
+ ///
+ ////////////////////////////////////////////////////////////
+ bool IsOk() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the response status code
+ ///
+ /// \return Status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Status GetStatus() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the full message contained in the response
+ ///
+ /// \return The response message
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetMessage() const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ Status myStatus; ///< Status code returned from the server
+ std::string myMessage; ///< Last message received from the server
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Specialization of FTP response returning a directory
+ ////////////////////////////////////////////////////////////
+ class DirectoryResponse : public Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Resp : Source response
+ ///
+ ////////////////////////////////////////////////////////////
+ DirectoryResponse(Response Resp);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the directory returned in the response
+ ///
+ /// \return Directory name
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetDirectory() const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ std::string myDirectory; ///< Directory extracted from the response message
+ };
+
+
+ ////////////////////////////////////////////////////////////
+ /// Specialization of FTP response returning a filename lisiting
+ ////////////////////////////////////////////////////////////
+ class ListingResponse : public Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param Resp : Source response
+ /// \param Data : Data containing the raw listing
+ ///
+ ////////////////////////////////////////////////////////////
+ ListingResponse(Response Resp, const std::vector<char>& Data);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the number of filenames in the listing
+ ///
+ /// \return Total number of filenames
+ ///
+ ////////////////////////////////////////////////////////////
+ std::size_t GetCount() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the Index-th filename in the directory
+ ///
+ /// \param Index : Index of the filename to get
+ ///
+ /// \return Index-th filename
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetFilename(std::size_t Index) const;
+
+ private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ std::vector<std::string> myFilenames; ///< Filenames extracted from the data
+ };
+
+
+ ////////////////////////////////////////////////////////////
+ /// Destructor -- close the connection with the server
+ ///
+ ////////////////////////////////////////////////////////////
+ ~Ftp();
+
+ ////////////////////////////////////////////////////////////
+ /// Connect to the specified FTP server
+ ///
+ /// \param Server : FTP server to connect to
+ /// \param Port : Port used for connection (21 by default, standard FTP port)
+ /// \param Timeout : Maximum time to wait, in seconds (0 by default, means no timeout)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Connect(const IPAddress& Server, unsigned short Port = 21, float Timeout = 0.f);
+
+ ////////////////////////////////////////////////////////////
+ /// Log in using anonymous account
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Login();
+
+ ////////////////////////////////////////////////////////////
+ /// Log in using a username and a password
+ ///
+ /// \param UserName : User name
+ /// \param Password : Password
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Login(const std::string& UserName, const std::string& Password);
+
+ ////////////////////////////////////////////////////////////
+ /// Close the connection with FTP server
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Disconnect();
+
+ ////////////////////////////////////////////////////////////
+ /// Send a null command just to prevent from being disconnected
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response KeepAlive();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the current working directory
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ DirectoryResponse GetWorkingDirectory();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the contents of the given directory
+ /// (subdirectories and files)
+ ///
+ /// \param Directory : Directory to list ("" by default, the current one)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ ListingResponse GetDirectoryListing(const std::string& Directory = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Change the current working directory
+ ///
+ /// \param Directory : New directory, relative to the current one
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response ChangeDirectory(const std::string& Directory);
+
+ ////////////////////////////////////////////////////////////
+ /// Go to the parent directory of the current one
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response ParentDirectory();
+
+ ////////////////////////////////////////////////////////////
+ /// Create a new directory
+ ///
+ /// \param Name : Name of the directory to create
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response MakeDirectory(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove an existing directory
+ ///
+ /// \param Name : Name of the directory to remove
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response DeleteDirectory(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Rename a file
+ ///
+ /// \param File : File to rename
+ /// \param NewName : New name
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response RenameFile(const std::string& File, const std::string& NewName);
+
+ ////////////////////////////////////////////////////////////
+ /// Remove an existing file
+ ///
+ /// \param Name : File to remove
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response DeleteFile(const std::string& Name);
+
+ ////////////////////////////////////////////////////////////
+ /// Download a file from the server
+ ///
+ /// \param DistantFile : Path of the distant file to download
+ /// \param DestPath : Where to put to file on the local computer
+ /// \param Mode : Transfer mode (binary by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Download(const std::string& DistantFile, const std::string& DestPath, TransferMode Mode = Binary);
+
+ ////////////////////////////////////////////////////////////
+ /// Upload a file to the server
+ ///
+ /// \param LocalFile : Path of the local file to upload
+ /// \param DestPath : Where to put to file on the server
+ /// \param Mode : Transfer mode (binary by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response Upload(const std::string& LocalFile, const std::string& DestPath, TransferMode Mode = Binary);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ /// Send a command to the FTP server
+ ///
+ /// \param Command : Command to send
+ /// \param Parameter : Command parameter ("" by default)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response SendCommand(const std::string& Command, const std::string& Parameter = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Receive a response from the server
+ /// (usually after a command has been sent)
+ ///
+ /// \return Server response to the request
+ ///
+ ////////////////////////////////////////////////////////////
+ Response GetResponse();
+
+ ////////////////////////////////////////////////////////////
+ /// Utility class for exchanging datas with the server
+ /// on the data channel
+ ////////////////////////////////////////////////////////////
+ class DataChannel;
+
+ friend class DataChannel;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketTCP myCommandSocket; ///< Socket holding the control connection with the server
+};
+
+} // namespace sf
+
+
+#endif // SFML_FTP_HPP
diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp
new file mode 100644
index 0000000..3e02531
--- /dev/null
+++ b/include/SFML/Network/Http.hpp
@@ -0,0 +1,339 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_HTTP_HPP
+#define SFML_HTTP_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NonCopyable.hpp>
+#include <SFML/Network/IPAddress.hpp>
+#include <SFML/Network/SocketTCP.hpp>
+#include <map>
+#include <string>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// This class provides methods for manipulating the HTTP
+/// protocol (described in RFC 1945).
+/// It can connect to a website, get its files, send requests, etc.
+////////////////////////////////////////////////////////////
+class SFML_API Http : NonCopyable
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps an HTTP request, which is basically :
+ /// - a header with a method, a target URI, and a set of field/value pairs
+ /// - an optional body (for POST requests)
+ ////////////////////////////////////////////////////////////
+ class SFML_API Request
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate the available HTTP methods for a request
+ ////////////////////////////////////////////////////////////
+ enum Method
+ {
+ Get, ///< Request in get mode, standard method to retrieve a page
+ Post, ///< Request in post mode, usually to send data to a page
+ Head ///< Request a page's header only
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ /// \param RequestMethod : Method to use for the request (Get by default)
+ /// \param URI : Target URI ("/" by default -- index page)
+ /// \param Body : Content of the request's body (empty by default)
+ ///
+ ////////////////////////////////////////////////////////////
+ Request(Method RequestMethod = Get, const std::string& URI = "/", const std::string& Body = "");
+
+ ////////////////////////////////////////////////////////////
+ /// Set the value of a field; the field is added if it doesn't exist
+ ///
+ /// \param Field : Name of the field to set (case-insensitive)
+ /// \param Value : Value of the field
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetField(const std::string& Field, const std::string& Value);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the request method.
+ /// This parameter is Http::Request::Get by default
+ ///
+ /// \param RequestMethod : Method to use for the request
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetMethod(Method RequestMethod);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the target URI of the request.
+ /// This parameter is "/" by default
+ ///
+ /// \param URI : URI to request, local to the host
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetURI(const std::string& URI);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the HTTP version of the request.
+ /// This parameter is 1.0 by default
+ ///
+ /// \param Major : Major version number
+ /// \param Minor : Minor version number
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetHttpVersion(unsigned int Major, unsigned int Minor);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the body of the request. This parameter is optional and
+ /// makes sense only for POST requests.
+ /// This parameter is empty by default
+ ///
+ /// \param Body : Content of the request body
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetBody(const std::string& Body);
+
+ private :
+
+ friend class Http;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the string representation of the request header
+ ///
+ /// \return String containing the request
+ ///
+ ////////////////////////////////////////////////////////////
+ std::string ToString() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Check if the given field has been defined
+ ///
+ /// \param Field : Name of the field to check (case-insensitive)
+ ///
+ /// \return True if the field exists
+ ///
+ ////////////////////////////////////////////////////////////
+ bool HasField(const std::string& Field) const;
+
+ ////////////////////////////////////////////////////////////
+ // Types
+ ////////////////////////////////////////////////////////////
+ typedef std::map<std::string, std::string> FieldTable;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ FieldTable myFields; ///< Fields of the header
+ Method myMethod; ///< Method to use for the request
+ std::string myURI; ///< Target URI of the request
+ unsigned int myMajorVersion; ///< Major HTTP version
+ unsigned int myMinorVersion; ///< Minor HTTP version
+ std::string myBody; ///< Body of the request
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// This class wraps an HTTP response, which is basically :
+ /// - a header with a status code and a set of field/value pairs
+ /// - a body (the content of the requested resource)
+ ////////////////////////////////////////////////////////////
+ class SFML_API Response
+ {
+ public :
+
+ ////////////////////////////////////////////////////////////
+ /// Enumerate all the valid status codes returned in
+ /// a HTTP response
+ ////////////////////////////////////////////////////////////
+ enum Status
+ {
+ // 2xx: success
+ Ok = 200, ///< Most common code returned when operation was successful
+ Created = 201, ///< The resource has successfully been created
+ Accepted = 202, ///< The request has been accepted, but will be processed later by the server
+ NoContent = 204, ///< Sent when the server didn't send any data in return
+
+ // 3xx: redirection
+ MultipleChoices = 300, ///< The requested page can be accessed from several locations
+ MovedPermanently = 301, ///< The requested page has permanently moved to a new location
+ MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
+ NotModified = 304, ///< For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed
+
+ // 4xx: client error
+ BadRequest = 400, ///< The server couldn't understand the request (syntax error)
+ Unauthorized = 401, ///< The requested page needs an authentification to be accessed
+ Forbidden = 403, ///< The requested page cannot be accessed at all, even with authentification
+ NotFound = 404, ///< The requested page doesn't exist
+
+ // 5xx: server error
+ InternalServerError = 500, ///< The server encountered an unexpected error
+ NotImplemented = 501, ///< The server doesn't implement a requested feature
+ BadGateway = 502, ///< The gateway server has received an error from the source server
+ ServiceNotAvailable = 503, ///< The server is temporarily unavailable (overloaded, in maintenance, ...)
+
+ // 10xx: SFML custom codes
+ InvalidResponse = 1000, ///< Response is not a valid HTTP one
+ ConnectionFailed = 1001 ///< Connection with server failed
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ Response();
+
+ ////////////////////////////////////////////////////////////
+ /// Get the value of a field
+ ///
+ /// \param Field : Name of the field to get (case-insensitive)
+ ///
+ /// \return Value of the field, or empty string if not found
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetField(const std::string& Field) const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the header's status code
+ ///
+ /// \return Header's status code
+ ///
+ ////////////////////////////////////////////////////////////
+ Status GetStatus() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the major HTTP version number of the response
+ ///
+ /// \return Major version number
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int GetMajorHttpVersion() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the major HTTP version number of the response
+ ///
+ /// \return Major version number
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int GetMinorHttpVersion() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Get the body of the response. The body can contain :
+ /// - the requested page (for GET requests)
+ /// - a response from the server (for POST requests)
+ /// - nothing (for HEAD requests)
+ /// - an error message (in case of an error)
+ ///
+ /// \return The response body
+ ///
+ ////////////////////////////////////////////////////////////
+ const std::string& GetBody() const;
+
+ private :
+
+ friend class Http;
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the header from a response string
+ ///
+ /// \param Data : Content of the response's header to parse
+ ///
+ ////////////////////////////////////////////////////////////
+ void FromString(const std::string& Data);
+
+ ////////////////////////////////////////////////////////////
+ // Types
+ ////////////////////////////////////////////////////////////
+ typedef std::map<std::string, std::string> FieldTable;
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ FieldTable myFields; ///< Fields of the header
+ Status myStatus; ///< Status code
+ unsigned int myMajorVersion; ///< Major HTTP version
+ unsigned int myMinorVersion; ///< Minor HTTP version
+ std::string myBody; ///< Body of the response
+ };
+
+ ////////////////////////////////////////////////////////////
+ /// Default constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ Http();
+
+ ////////////////////////////////////////////////////////////
+ /// Construct the Http instance with the target host
+ ///
+ /// \param Host : Web server to connect to
+ /// \param Port : Port to use for connection (0 by default -- use the standard port of the protocol used)
+ ///
+ ////////////////////////////////////////////////////////////
+ Http(const std::string& Host, unsigned short Port = 0);
+
+ ////////////////////////////////////////////////////////////
+ /// Set the target host
+ ///
+ /// \param Host : Web server to connect to
+ /// \param Port : Port to use for connection (0 by default -- use the standard port of the protocol used)
+ ///
+ ////////////////////////////////////////////////////////////
+ void SetHost(const std::string& Host, unsigned short Port = 0);
+
+ ////////////////////////////////////////////////////////////
+ /// Send a HTTP request and return the server's response.
+ /// You must be connected to a host before sending requests.
+ /// Any missing mandatory header field will be added with an appropriate value.
+ /// Warning : this function waits for the server's response and may
+ /// not return instantly; use a thread if you don't want to block your
+ /// application.
+ ///
+ /// \param Req : Request to send
+ ///
+ /// \return Server's response
+ ///
+ ////////////////////////////////////////////////////////////
+ Response SendRequest(const Request& Req);
+
+private :
+
+ ////////////////////////////////////////////////////////////
+ // Member data
+ ////////////////////////////////////////////////////////////
+ SocketTCP myConnection; ///< Connection to the host
+ IPAddress myHost; ///< Web host address
+ std::string myHostName; ///< Web host name
+ unsigned short myPort; ///< Port used for connection with host
+};
+
+} // namespace sf
+
+
+#endif // SFML_HTTP_HPP
diff --git a/include/SFML/Network/IPAddress.hpp b/include/SFML/Network/IPAddress.hpp
index 5721623..8373315 100755..100644
--- a/include/SFML/Network/IPAddress.hpp
+++ b/include/SFML/Network/IPAddress.hpp
@@ -78,6 +78,14 @@ public :
IPAddress(Uint8 Byte0, Uint8 Byte1, Uint8 Byte2, Uint8 Byte3);
////////////////////////////////////////////////////////////
+ /// Construct the address from a 32-bits integer
+ ///
+ /// \param Address : 4 bytes of the address packed into a 32-bits integer
+ ///
+ ////////////////////////////////////////////////////////////
+ IPAddress(Uint32 Address);
+
+ ////////////////////////////////////////////////////////////
/// Tell if the address is a valid one
///
/// \return True if address has a valid syntax
@@ -94,6 +102,14 @@ public :
std::string ToString() const;
////////////////////////////////////////////////////////////
+ /// Get an integer representation of the address
+ ///
+ /// \return 32-bits integer containing the 4 bytes of the address, in system endianness
+ ///
+ ////////////////////////////////////////////////////////////
+ Uint32 ToInteger() const;
+
+ ////////////////////////////////////////////////////////////
/// Get the computer's local IP address (from the LAN point of view)
///
/// \return Local IP address
diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp
index 738dfce..3add17f 100755..100644
--- a/include/SFML/Network/Packet.hpp
+++ b/include/SFML/Network/Packet.hpp
@@ -85,12 +85,20 @@ public :
/// \return Data size, in bytes
///
////////////////////////////////////////////////////////////
- Uint32 GetDataSize() const;
+ std::size_t GetDataSize() const;
////////////////////////////////////////////////////////////
- /// Tell if the packet is valid for reading
+ /// Tell if the reading position has reached the end of the packet
///
- /// \return True if data can be extracted from the packet
+ /// \return True if all data have been read into the packet
+ ///
+ ////////////////////////////////////////////////////////////
+ bool EndOfPacket() const;
+
+ ////////////////////////////////////////////////////////////
+ /// Return the validity of packet
+ ///
+ /// \return True if last data extraction from packet was successful
///
////////////////////////////////////////////////////////////
operator bool() const;
@@ -99,6 +107,7 @@ public :
/// Operator >> overloads to extract data from the packet
///
////////////////////////////////////////////////////////////
+ Packet& operator >>(bool& Data);
Packet& operator >>(Int8& Data);
Packet& operator >>(Uint8& Data);
Packet& operator >>(Int16& Data);
@@ -116,6 +125,7 @@ public :
/// Operator << overloads to put data into the packet
///
////////////////////////////////////////////////////////////
+ Packet& operator <<(bool Data);
Packet& operator <<(Int8 Data);
Packet& operator <<(Uint8 Data);
Packet& operator <<(Int16 Data);
@@ -147,14 +157,21 @@ private :
////////////////////////////////////////////////////////////
/// Called before the packet is sent to the network
///
+ /// \param DataSize : Variable to fill with the size of data to send
+ ///
+ /// \return Pointer to the array of bytes to send
+ ///
////////////////////////////////////////////////////////////
- virtual void OnSend();
+ virtual const char* OnSend(std::size_t& DataSize);
////////////////////////////////////////////////////////////
/// Called after the packet has been received from the network
///
+ /// \param Data : Pointer to the array of received bytes
+ /// \param DataSize : Size of the array of bytes
+ ///
////////////////////////////////////////////////////////////
- virtual void OnReceive();
+ virtual void OnReceive(const char* Data, std::size_t DataSize);
////////////////////////////////////////////////////////////
// Member data
diff --git a/include/SFML/Network/Selector.hpp b/include/SFML/Network/Selector.hpp
index 7d1c320..3ab7dfa 100755..100644
--- a/include/SFML/Network/Selector.hpp
+++ b/include/SFML/Network/Selector.hpp
@@ -89,7 +89,7 @@ public :
/// \return The Index-th socket
///
////////////////////////////////////////////////////////////
- Type GetSocketReady(unsigned int Index) const;
+ Type GetSocketReady(unsigned int Index);
private :
diff --git a/include/SFML/Network/Selector.inl b/include/SFML/Network/Selector.inl
index 9eacb6f..326c994 100755..100644
--- a/include/SFML/Network/Selector.inl
+++ b/include/SFML/Network/Selector.inl
@@ -85,7 +85,7 @@ unsigned int Selector<Type>::Wait(float Timeout)
/// is the integer returned by the previous call to Wait()
////////////////////////////////////////////////////////////
template <typename Type>
-Type Selector<Type>::GetSocketReady(unsigned int Index) const
+Type Selector<Type>::GetSocketReady(unsigned int Index)
{
SocketHelper::SocketType Socket = SelectorBase::GetSocketReady(Index);
diff --git a/include/SFML/Network/SelectorBase.hpp b/include/SFML/Network/SelectorBase.hpp
index 103c103..433e789 100755..100644
--- a/include/SFML/Network/SelectorBase.hpp
+++ b/include/SFML/Network/SelectorBase.hpp
@@ -94,7 +94,7 @@ public :
/// \return The Index-th socket
///
////////////////////////////////////////////////////////////
- SocketHelper::SocketType GetSocketReady(unsigned int Index) const;
+ SocketHelper::SocketType GetSocketReady(unsigned int Index);
private :
diff --git a/include/SFML/Network/SocketHelper.hpp b/include/SFML/Network/SocketHelper.hpp
index 36126db..36126db 100755..100644
--- a/include/SFML/Network/SocketHelper.hpp
+++ b/include/SFML/Network/SocketHelper.hpp
diff --git a/include/SFML/Network/SocketTCP.hpp b/include/SFML/Network/SocketTCP.hpp
index 06bcf9e..452b304 100755..100644
--- a/include/SFML/Network/SocketTCP.hpp
+++ b/include/SFML/Network/SocketTCP.hpp
@@ -29,12 +29,12 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/SocketHelper.hpp>
-#include <SFML/Network/Packet.hpp>
-#include <cstddef>
+#include <vector>
namespace sf
{
+class Packet;
class IPAddress;
template <typename> class Selector;
@@ -66,11 +66,12 @@ public :
///
/// \param Port : Port to use for transfers (warning : ports < 1024 are reserved)
/// \param HostAddress : IP Address of the host to connect to
+ /// \param Timeout : Maximum time to wait, in seconds (0 by default : no timeout) (this parameter is ignored for non-blocking sockets)
///
/// \return True if operation has been successful
///
////////////////////////////////////////////////////////////
- bool Connect(unsigned short Port, const IPAddress& HostAddress);
+ Socket::Status Connect(unsigned short Port, const IPAddress& HostAddress, float Timeout = 0.f);
////////////////////////////////////////////////////////////
/// Listen to a specified port for incoming data or connections
@@ -204,15 +205,18 @@ private :
////////////////////////////////////////////////////////////
/// Create the socket
///
+ /// \param Descriptor : System socket descriptor to use (0 by default -- create a new socket)
+ ///
////////////////////////////////////////////////////////////
- void Create();
+ void Create(SocketHelper::SocketType Descriptor = 0);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
SocketHelper::SocketType mySocket; ///< Socket descriptor
- sf::Packet myPendingPacket; ///< Current pending packet, if any (in non-blocking mode)
+ std::vector<char> myPendingPacket; ///< Data of the current pending packet, if any (in non-blocking mode)
Int32 myPendingPacketSize; ///< Size of the current pending packet, if any (in non-blocking mode)
+ bool myIsBlocking; ///< Is the socket blocking or non-blocking ?
};
} // namespace sf
diff --git a/include/SFML/Network/SocketUDP.hpp b/include/SFML/Network/SocketUDP.hpp
index 62229b4..ba43762 100755..100644
--- a/include/SFML/Network/SocketUDP.hpp
+++ b/include/SFML/Network/SocketUDP.hpp
@@ -29,12 +29,12 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/SocketHelper.hpp>
-#include <SFML/Network/Packet.hpp>
-#include <cstddef>
+#include <vector>
namespace sf
{
+class Packet;
class IPAddress;
template <typename> class Selector;
@@ -203,16 +203,19 @@ private :
////////////////////////////////////////////////////////////
/// Create the socket
///
+ /// \param Descriptor : System socket descriptor to use (0 by default -- create a new socket)
+ ///
////////////////////////////////////////////////////////////
- void Create();
+ void Create(SocketHelper::SocketType Descriptor = 0);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
SocketHelper::SocketType mySocket; ///< Socket identifier
unsigned short myPort; ///< Port to which the socket is bound
- sf::Packet myPendingPacket; ///< Current pending packet, if any (in non-blocking mode)
+ std::vector<char> myPendingPacket; ///< Data of the current pending packet, if any (in non-blocking mode)
Int32 myPendingPacketSize; ///< Size of the current pending packet, if any (in non-blocking mode)
+ bool myIsBlocking; ///< Is the socket blocking or non-blocking ?
};
} // namespace sf
diff --git a/include/SFML/Network/Sockets.hpp b/include/SFML/Network/Sockets.hpp
index b611e85..b611e85 100755..100644
--- a/include/SFML/Network/Sockets.hpp
+++ b/include/SFML/Network/Sockets.hpp
diff --git a/include/SFML/Network/Unix/.svn/all-wcprops b/include/SFML/Network/Unix/.svn/all-wcprops
new file mode 100644
index 0000000..f76fe19
--- /dev/null
+++ b/include/SFML/Network/Unix/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 52
+/svnroot/sfml/!svn/ver/749/include/SFML/Network/Unix
+END
+SocketHelper.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 69
+/svnroot/sfml/!svn/ver/749/include/SFML/Network/Unix/SocketHelper.hpp
+END
diff --git a/include/SFML/Network/Unix/.svn/entries b/include/SFML/Network/Unix/.svn/entries
new file mode 100644
index 0000000..729d880
--- /dev/null
+++ b/include/SFML/Network/Unix/.svn/entries
@@ -0,0 +1,62 @@
+9
+
+dir
+915
+https://sfml.svn.sourceforge.net/svnroot/sfml/include/SFML/Network/Unix
+https://sfml.svn.sourceforge.net/svnroot/sfml
+
+
+
+2008-07-05T13:12:12.731009Z
+749
+laurentgom
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4e206d99-4929-0410-ac5d-dfc041789085
+
+SocketHelper.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+bbdd460368f5bbb6eec8bb31ac30429a
+2008-07-05T13:12:12.731009Z
+749
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3392
+
diff --git a/include/SFML/Network/Unix/.svn/format b/include/SFML/Network/Unix/.svn/format
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/include/SFML/Network/Unix/.svn/format
@@ -0,0 +1 @@
+9
diff --git a/include/SFML/Network/Unix/.svn/text-base/SocketHelper.hpp.svn-base b/include/SFML/Network/Unix/.svn/text-base/SocketHelper.hpp.svn-base
new file mode 100644
index 0000000..1068cd8
--- /dev/null
+++ b/include/SFML/Network/Unix/.svn/text-base/SocketHelper.hpp.svn-base
@@ -0,0 +1,96 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETHELPERUNIX_HPP
+#define SFML_SOCKETHELPERUNIX_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <unistd.h>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// This class defines helper functions to do all the
+/// non-portable socket stuff. This class is meant for internal
+/// use only
+////////////////////////////////////////////////////////////
+class SFML_API SocketHelper
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ // Define some socket types
+ ////////////////////////////////////////////////////////////
+ typedef int SocketType;
+ typedef socklen_t LengthType;
+
+ ////////////////////////////////////////////////////////////
+ /// Return the value of the invalid socket
+ ///
+ /// \return Unique value of the invalid socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static SocketType InvalidSocket();
+
+ ////////////////////////////////////////////////////////////
+ /// Close / destroy a socket
+ ///
+ /// \param Socket : Socket to close
+ ///
+ /// \return True on success
+ ///
+ ////////////////////////////////////////////////////////////
+ static bool Close(SocketType Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Set a socket as blocking or non-blocking
+ ///
+ /// \param Socket : Socket to modify
+ /// \param Block : New blocking state of the socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static void SetBlocking(SocketType Socket, bool Block);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the last socket error status
+ ///
+ /// \return Status corresponding to the last socket error
+ ///
+ ////////////////////////////////////////////////////////////
+ static Socket::Status GetErrorStatus();
+};
+
+} // namespace sf
+
+
+#endif // SFML_SOCKETHELPERUNIX_HPP
diff --git a/include/SFML/Network/Unix/SocketHelper.hpp b/include/SFML/Network/Unix/SocketHelper.hpp
index 8a3b391..1068cd8 100755..100644
--- a/include/SFML/Network/Unix/SocketHelper.hpp
+++ b/include/SFML/Network/Unix/SocketHelper.hpp
@@ -1,95 +1,96 @@
-////////////////////////////////////////////////////////////
-//
-// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it freely,
-// subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented;
-// you must not claim that you wrote the original software.
-// If you use this software in a product, an acknowledgment
-// in the product documentation would be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such,
-// and must not be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-//
-////////////////////////////////////////////////////////////
-
-#ifndef SFML_SOCKETHELPERUNIX_HPP
-#define SFML_SOCKETHELPERUNIX_HPP
-
-////////////////////////////////////////////////////////////
-// Headers
-////////////////////////////////////////////////////////////
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-
-
-namespace sf
-{
-////////////////////////////////////////////////////////////
-/// This class defines helper functions to do all the
-/// non-portable socket stuff. This class is meant for internal
-/// use only
-////////////////////////////////////////////////////////////
-class SFML_API SocketHelper
-{
-public :
-
- ////////////////////////////////////////////////////////////
- // Define some socket types
- ////////////////////////////////////////////////////////////
- typedef int SocketType;
- typedef socklen_t LengthType;
-
- ////////////////////////////////////////////////////////////
- /// Return the value of the invalid socket
- ///
- /// \return Unique value of the invalid socket
- ///
- ////////////////////////////////////////////////////////////
- static SocketType InvalidSocket();
-
- ////////////////////////////////////////////////////////////
- /// Close / destroy a socket
- ///
- /// \param Socket : Socket to close
- ///
- /// \return True on success
- ///
- ////////////////////////////////////////////////////////////
- static bool Close(SocketType Socket);
-
- ////////////////////////////////////////////////////////////
- /// Set a socket as blocking or non-blocking
- ///
- /// \param Socket : Socket to modify
- /// \param Block : New blocking state of the socket
- ///
- ////////////////////////////////////////////////////////////
- static void SetBlocking(SocketType Socket, bool Block);
-
- ////////////////////////////////////////////////////////////
- /// Get the last socket error status
- ///
- /// \return Status corresponding to the last socket error
- ///
- ////////////////////////////////////////////////////////////
- static Socket::Status GetErrorStatus();
-};
-
-} // namespace sf
-
-
-#endif // SFML_SOCKETHELPERUNIX_HPP
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETHELPERUNIX_HPP
+#define SFML_SOCKETHELPERUNIX_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <unistd.h>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// This class defines helper functions to do all the
+/// non-portable socket stuff. This class is meant for internal
+/// use only
+////////////////////////////////////////////////////////////
+class SFML_API SocketHelper
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ // Define some socket types
+ ////////////////////////////////////////////////////////////
+ typedef int SocketType;
+ typedef socklen_t LengthType;
+
+ ////////////////////////////////////////////////////////////
+ /// Return the value of the invalid socket
+ ///
+ /// \return Unique value of the invalid socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static SocketType InvalidSocket();
+
+ ////////////////////////////////////////////////////////////
+ /// Close / destroy a socket
+ ///
+ /// \param Socket : Socket to close
+ ///
+ /// \return True on success
+ ///
+ ////////////////////////////////////////////////////////////
+ static bool Close(SocketType Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Set a socket as blocking or non-blocking
+ ///
+ /// \param Socket : Socket to modify
+ /// \param Block : New blocking state of the socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static void SetBlocking(SocketType Socket, bool Block);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the last socket error status
+ ///
+ /// \return Status corresponding to the last socket error
+ ///
+ ////////////////////////////////////////////////////////////
+ static Socket::Status GetErrorStatus();
+};
+
+} // namespace sf
+
+
+#endif // SFML_SOCKETHELPERUNIX_HPP
diff --git a/include/SFML/Network/Win32/.svn/all-wcprops b/include/SFML/Network/Win32/.svn/all-wcprops
new file mode 100644
index 0000000..8626588
--- /dev/null
+++ b/include/SFML/Network/Win32/.svn/all-wcprops
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 53
+/svnroot/sfml/!svn/ver/434/include/SFML/Network/Win32
+END
+SocketHelper.hpp
+K 25
+svn:wc:ra_dav:version-url
+V 70
+/svnroot/sfml/!svn/ver/434/include/SFML/Network/Win32/SocketHelper.hpp
+END
diff --git a/include/SFML/Network/Win32/.svn/entries b/include/SFML/Network/Win32/.svn/entries
new file mode 100644
index 0000000..a01813d
--- /dev/null
+++ b/include/SFML/Network/Win32/.svn/entries
@@ -0,0 +1,62 @@
+9
+
+dir
+915
+https://sfml.svn.sourceforge.net/svnroot/sfml/include/SFML/Network/Win32
+https://sfml.svn.sourceforge.net/svnroot/sfml
+
+
+
+2008-01-23T16:10:18.126022Z
+434
+laurentgom
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+4e206d99-4929-0410-ac5d-dfc041789085
+
+SocketHelper.hpp
+file
+
+
+
+
+2008-11-01T16:23:32.000000Z
+189b7e68dbf625a38637bc56ccff94c6
+2008-01-23T16:10:18.126022Z
+434
+laurentgom
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3252
+
diff --git a/include/SFML/Network/Win32/.svn/format b/include/SFML/Network/Win32/.svn/format
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/include/SFML/Network/Win32/.svn/format
@@ -0,0 +1 @@
+9
diff --git a/include/SFML/Network/Win32/.svn/text-base/SocketHelper.hpp.svn-base b/include/SFML/Network/Win32/.svn/text-base/SocketHelper.hpp.svn-base
new file mode 100644
index 0000000..d7851b4
--- /dev/null
+++ b/include/SFML/Network/Win32/.svn/text-base/SocketHelper.hpp.svn-base
@@ -0,0 +1,90 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_SOCKETHELPERWIN32_HPP
+#define SFML_SOCKETHELPERWIN32_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <winsock2.h>
+
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// This class defines helper functions to do all the
+/// non-portable socket stuff. This class is meant for internal
+/// use only
+////////////////////////////////////////////////////////////
+class SFML_API SocketHelper
+{
+public :
+
+ ////////////////////////////////////////////////////////////
+ // Define some socket types
+ ////////////////////////////////////////////////////////////
+ typedef SOCKET SocketType;
+ typedef int LengthType;
+
+ ////////////////////////////////////////////////////////////
+ /// Return the value of the invalid socket
+ ///
+ /// \return Unique value of the invalid socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static SocketType InvalidSocket();
+
+ ////////////////////////////////////////////////////////////
+ /// Close / destroy a socket
+ ///
+ /// \param Socket : Socket to close
+ ///
+ /// \return True on success
+ ///
+ ////////////////////////////////////////////////////////////
+ static bool Close(SocketType Socket);
+
+ ////////////////////////////////////////////////////////////
+ /// Set a socket as blocking or non-blocking
+ ///
+ /// \param Socket : Socket to modify
+ /// \param Block : New blocking state of the socket
+ ///
+ ////////////////////////////////////////////////////////////
+ static void SetBlocking(SocketType Socket, bool Block);
+
+ ////////////////////////////////////////////////////////////
+ /// Get the last socket error status
+ ///
+ /// \return Status corresponding to the last socket error
+ ///
+ ////////////////////////////////////////////////////////////
+ static Socket::Status GetErrorStatus();
+};
+
+} // namespace sf
+
+
+#endif // SFML_SOCKETHELPERWIN32_HPP
diff --git a/include/SFML/Network/Win32/SocketHelper.hpp b/include/SFML/Network/Win32/SocketHelper.hpp
index d7851b4..d7851b4 100755..100644
--- a/include/SFML/Network/Win32/SocketHelper.hpp
+++ b/include/SFML/Network/Win32/SocketHelper.hpp