| jconnection.h | | jconnection.h | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| #include <windows.h> | | #include <windows.h> | |
| #include <winsock.h> | | #include <winsock.h> | |
| #else | | #else | |
| #include <sys/socket.h> | | #include <sys/socket.h> | |
| #endif | | #endif | |
| | | | |
| namespace jsocket { | | namespace jsocket { | |
| | | | |
|
| | | #ifdef _WIN32 | |
| | | typedef SOCKET jsocket_t; | |
| | | #else | |
| | | typedef int jsocket_t; | |
| | | #endif | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| enum jconnection_type_t { | | enum jconnection_type_t { | |
| TCP_SOCKET, | | TCP_SOCKET, | |
| UDP_SOCKET, | | UDP_SOCKET, | |
| MCAST_SOCKET, | | MCAST_SOCKET, | |
| RTP_SOCKET, | | RTP_SOCKET, | |
| RAW_SOCKET, | | RAW_SOCKET, | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 71 | |
| */ | | */ | |
| class Connection : public virtual jcommon::Object{ | | class Connection : public virtual jcommon::Object{ | |
| | | | |
| friend class DatagramSocket; | | friend class DatagramSocket; | |
| friend class Socket; | | friend class Socket; | |
| friend class RTPSocket; | | friend class RTPSocket; | |
| friend class MulticastSocket; | | friend class MulticastSocket; | |
| friend class RawSocket; | | friend class RawSocket; | |
| | | | |
| protected: | | protected: | |
|
| /** \brief */ | | /** \brief */ | |
| jconnection_type_t _type; | | jconnection_type_t _type; | |
| /** \brief */ | | /** \brief */ | |
| bool _is_closed; | | bool _is_closed; | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| Connection(jconnection_type_t type); | | Connection(jconnection_type_t type); | |
| | | | |
| public: | | public: | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jconnection_type_t GetType(); | | virtual jconnection_type_t GetType(); | |
| | | | |
|
| /** | | /** | |
| * \brief Send bytes to a destination. | | * \brief Send bytes to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual bool IsClosed(); | | virtual int Send(const char *b_, int size_, bool block_ = tr | |
| | | ue) = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Send bytes to a destination. | | * \brief Send bytes to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual int Send(const char *b_, int size_, bool block_ = true) = 0; | | virtual int Send(const char *b_, int size_, int time_) = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Send bytes to a destination. | | * \brief Receive bytes from a source. | |
| * | | * | |
| */ | | * \return the number of bytes received, or 0 if the peer ha | |
| virtual int Send(const char *b_, int size_, int time_) = 0; | | s shutdown. | |
| | | * | |
| | | * \exception SocketException an error occurred. | |
| | | * | |
| | | */ | |
| | | virtual int Receive(char *data_, int data_length_, bool bloc | |
| | | k_ = true) = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Receive bytes from a source. | | * \brief Receive bytes from a source. | |
| * | | * | |
| * \return the number of bytes received, or 0 if the peer has shutdo | | * \return the number of bytes received, or 0 if the peer ha | |
| wn. | | s shutdown. | |
| * | | * | |
| * \exception SocketException an error occurred. | | * \exception SocketException an error occurred. | |
| * | | * | |
| */ | | */ | |
| virtual int Receive(char *data_, int data_length_, bool block_ = tru | | virtual int Receive(char *data_, int data_length_, int time_ | |
| e) = 0; | | ) = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Receive bytes from a source. | | * \brief | |
| * | | * | |
| * \return the number of bytes received, or 0 if the peer has shutdo | | */ | |
| wn. | | virtual bool IsClosed(); | |
| * | | | |
| * \exception SocketException an error occurred. | | | |
| * | | | |
| */ | | | |
| virtual int Receive(char *data_, int data_length_, int time_) = 0; | | | |
| | | | |
|
| /** | | /** | |
| * \brief Close the socket. | | * \brief Close the socket. | |
| * | | * | |
| */ | | */ | |
| virtual void Close() = 0; | | virtual void Close() = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| #ifdef _WIN32 | | virtual jsocket_t GetHandler() = 0; | |
| virtual SOCKET GetHandler() = 0; | | | |
| #else | | | |
| virtual int GetHandler() = 0; | | | |
| #endif | | | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::InputStream * GetInputStream() = 0; | | virtual jio::InputStream * GetInputStream() = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::OutputStream * GetOutputStream() = 0; | | virtual jio::OutputStream * GetOutputStream() = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Get the bytes sent to a destination. | | * \brief Get the bytes sent to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetSentBytes() = 0; | | virtual int64_t GetSentBytes() = 0; | |
| | | | |
|
| /** | | /** | |
| * \brief Get de bytes received from a source. | | * \brief Get de bytes received from a source. | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetReadedBytes() = 0; | | virtual int64_t GetReadedBytes() = 0; | |
| | | | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 15 change blocks. |
| 84 lines changed or deleted | | 88 lines changed or added | |
|
| jconnectionpipe.h | | jconnectionpipe.h | |
| | | | |
| skipping to change at line 57 | | skipping to change at line 57 | |
| SENDER_PIPE | | SENDER_PIPE | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * \brief ConnectionPipe. | | * \brief ConnectionPipe. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class ConnectionPipe : public jsocket::Connection, public jthread::Thread{ | | class ConnectionPipe : public jsocket::Connection, public jthread::Thread{ | |
| | | | |
|
| private: | | private: | |
| /** \brief Use to bind the socket in a free port. */ | | /** \brief Use to bind the socket in a free port. */ | |
| static int _used_port; | | static int _used_port; | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
|
| /** \brief */ | | /** \brief */ | |
| HANDLE *_pipe; | | HANDLE *_pipe; | |
|
| /** \brief */ | | /** \brief */ | |
| HANDLE _thread; | | HANDLE _thread; | |
|
| /** \brief */ | | /** \brief */ | |
| DWORD _thread_id; | | DWORD _thread_id; | |
|
| /** \brief */ | | /** \brief */ | |
| DWORD _stackSize; | | DWORD _stackSize; | |
|
| /** \brief */ | | /** \brief */ | |
| DWORD _executeFlag; | | DWORD _executeFlag; | |
|
| /** \brief */ | | /** \brief */ | |
| LPTHREAD_START_ROUTINE _threadFunction; | | LPTHREAD_START_ROUTINE _threadFunction; | |
|
| /** \brief */ | | /** \brief */ | |
| LPVOID _threadArgument; | | LPVOID _threadArgument; | |
|
| /** \brief */ | | /** \brief */ | |
| LPSECURITY_ATTRIBUTES _sa; | | LPSECURITY_ATTRIBUTES _sa; | |
| #else | | #else | |
|
| /** \brief */ | | /** \brief */ | |
| int _pipe[2]; | | int _pipe[2]; | |
|
| /** \brief */ | | /** \brief */ | |
| pthread_t _thread; | | pthread_t _thread; | |
| #endif | | #endif | |
| /** \brief */ | | /** \brief */ | |
| Connection *_connection; | | Connection *_connection; | |
|
| /** \brief */ | | /** \brief */ | |
| bool _stream; | | bool _stream; | |
|
| /** \brief */ | | /** \brief */ | |
| int _timeout; | | int _timeout; | |
|
| /** \brief */ | | /** \brief */ | |
| jconnection_pipe_t _pipe_type; | | | |
| /** \brief */ | | | |
| bool _is_running; | | bool _is_running; | |
|
| /** \brief */ | | /** \brief */ | |
| int _current_send; | | int _current_send; | |
|
| /** \brief */ | | /** \brief */ | |
| int _sent_bytes; | | int _sent_bytes; | |
|
| /** \brief */ | | /** \brief */ | |
| int _receive_bytes; | | int _receive_bytes; | |
|
| /** \brief */ | | /** \brief */ | |
| int _size_pipe; | | int _size_pipe; | |
|
| | | /** \brief */ | |
| | | jconnection_pipe_t _pipe_type; | |
| | | | |
|
| /** | | /** | |
| * \brief Create a new socket. | | * \brief Create a new socket. | |
| * | | * | |
| */ | | */ | |
| void main_pipe_receiver(); | | void main_pipe_receiver(); | |
| | | | |
|
| /** | | /** | |
| * \brief Create a new socket. | | * \brief Create a new socket. | |
| * | | * | |
| */ | | */ | |
| void main_pipe_sender(); | | void main_pipe_sender(); | |
| | | | |
|
| public: | | public: | |
| /** | | /** | |
| * \brief Construtor. | | * \brief Construtor. | |
| * | | * | |
| */ | | */ | |
| ConnectionPipe(Connection *conn, jconnection_pipe_t type_, int size | | ConnectionPipe(Connection *conn, jconnection_pipe_t type_, i | |
| _pipe_ = 4096, int timeout_ = 0, bool stream_ = false); | | nt size_pipe_ = 4096, int timeout_ = 0, bool stream_ = false); | |
| | | | |
|
| /** | | /** | |
| * \brief Destructor virtual. | | * \brief Destructor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~ConnectionPipe(); | | virtual ~ConnectionPipe(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| bool IsRunning(); | | bool IsRunning(); | |
| | | | |
|
| /** | | /** | |
| * \brief Read data from a source. | | * \brief Read data from a source. | |
| * | | * | |
| */ | | */ | |
| int Receive(char *data_, int size_, bool block_ = true); | | int Receive(char *data_, int size_, bool block_ = true); | |
| | | | |
|
| /** | | /** | |
| * \brief Read data from a source. | | * \brief Read data from a source. | |
| * | | * | |
| */ | | */ | |
| int Receive(char *data_, int size_, int time_); | | int Receive(char *data_, int size_, int time_); | |
| | | | |
| /** | | /** | |
|
| * \brief Write data to a source. | | * \brief Write data to a source. | |
| * | | * | |
| */ | | */ | |
| int Send(const char *data_, int size_, bool block_ = true); | | int Send(const char *data_, int size_, bool block_ = true); | |
| | | | |
|
| /** | | /** | |
| * \brief Write data to a source. | | * \brief Write data to a source. | |
| * | | * | |
| */ | | */ | |
| int Send(const char *data_, int size_, int time_); | | int Send(const char *data_, int size_, int time_); | |
| | | | |
|
| /** | | /** | |
| * \brief Close the socket. The pipe would be interrupted before clo | | * \brief Close the socket. The pipe would be interrupted be | |
| sed. | | fore closed. | |
| * | | * | |
| */ | | */ | |
| void Close(); | | void Close(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
|
| #ifdef _WIN32 | | virtual jsocket_t GetHandler(); | |
| virtual SOCKET GetHandler(); | | | |
| #else | | | |
| virtual int GetHandler(); | | | |
| #endif | | | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::InputStream * GetInputStream(); | | virtual jio::InputStream * GetInputStream(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::OutputStream * GetOutputStream(); | | virtual jio::OutputStream * GetOutputStream(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get sent bytes to destination. | | * \brief Get sent bytes to destination. | |
| * | | * | |
| */ | | */ | |
| int64_t GetSentBytes(); | | int64_t GetSentBytes(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get received bytes from a source. | | * \brief Get received bytes from a source. | |
| * | | * | |
| */ | | */ | |
| int64_t GetReadedBytes(); | | int64_t GetReadedBytes(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual void Run(); | | virtual void Run(); | |
| | | | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
End of changes. 34 change blocks. |
| 93 lines changed or deleted | | 89 lines changed or added | |
|
| jdatagramsocket.h | | jdatagramsocket.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_DATAGRAM_SOCKET_H | | #ifndef J_DATAGRAMSOCKET_H | |
| #define J_DATAGRAM_SOCKET_H | | #define J_DATAGRAMSOCKET_H | |
| | | | |
| #include "jinetaddress.h" | | #include "jinetaddress.h" | |
| #include "jsocketoption.h" | | #include "jsocketoption.h" | |
| #include "jsocketinputstream.h" | | #include "jsocketinputstream.h" | |
| #include "jsocketoutputstream.h" | | #include "jsocketoutputstream.h" | |
| #include "jconnection.h" | | #include "jconnection.h" | |
| | | | |
| #include <string> | | #include <string> | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| | | | |
| skipping to change at line 54 | | skipping to change at line 54 | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class DatagramSocket : public jsocket::Connection{ | | class DatagramSocket : public jsocket::Connection{ | |
| | | | |
| private: | | private: | |
| /** \brief Use to bind the socket in a free port. */ | | /** \brief Use to bind the socket in a free port. */ | |
| static int _used_port; | | static int _used_port; | |
| | | | |
| /** \brief Socket handler. */ | | /** \brief Socket handler. */ | |
|
| #ifdef _WIN32 | | jsocket_t _fd; | |
| SOCKET _fd; | | | |
| #else | | | |
| int _fd; | | | |
| #endif | | | |
| /** \brief Local socket. */ | | /** \brief Local socket. */ | |
|
| sockaddr_in _lsock; | | struct sockaddr_in _lsock; | |
| /** \brief Server socket UDP. */ | | /** \brief Server socket UDP. */ | |
|
| sockaddr_in _server_sock; | | struct sockaddr_in _server_sock; | |
| /** \brief Local inetaddress. */ | | /** \brief Local inetaddress. */ | |
| InetAddress *_local; | | InetAddress *_local; | |
| /** \brief Remote inetaddress. */ | | /** \brief Remote inetaddress. */ | |
| InetAddress *_address; | | InetAddress *_address; | |
| /** \brief Input stream. */ | | /** \brief Input stream. */ | |
| SocketInputStream *_is; | | SocketInputStream *_is; | |
| /** \brief Output stream. */ | | /** \brief Output stream. */ | |
| SocketOutputStream *_os; | | SocketOutputStream *_os; | |
| /** \brief Bytes sent. */ | | /** \brief Bytes sent. */ | |
| int64_t _sent_bytes; | | int64_t _sent_bytes; | |
| | | | |
| skipping to change at line 123 | | skipping to change at line 119 | |
| * | | * | |
| */ | | */ | |
| DatagramSocket(int port_, bool stream_ = false, int timeout_
= 0, int rbuf_ = 65535, int wbuf_ = 4096); | | DatagramSocket(int port_, bool stream_ = false, int timeout_
= 0, int rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
| /** | | /** | |
| * \brief Destructor virtual. | | * \brief Destructor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~DatagramSocket(); | | virtual ~DatagramSocket(); | |
| | | | |
|
| #ifdef _WIN32 | | /** | |
| virtual SOCKET GetHandler(); | | * \brief | |
| #else | | * | |
| virtual int GetHandler(); | | */ | |
| #endif | | virtual jsocket_t GetHandler(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::InputStream * GetInputStream(); | | virtual jio::InputStream * GetInputStream(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| | | | |
| skipping to change at line 172 | | skipping to change at line 168 | |
| */ | | */ | |
| virtual int Send(const char *data_, int size_, int time_); | | virtual int Send(const char *data_, int size_, int time_); | |
| | | | |
| /** | | /** | |
| * \brief Close the socket. | | * \brief Close the socket. | |
| * | | * | |
| */ | | */ | |
| virtual void Close(); | | virtual void Close(); | |
| | | | |
| /** | | /** | |
|
| * \brief | | | |
| * | | | |
| */ | | | |
| sockaddr_in LocalAddress(); | | | |
| | | | |
| /** | | | |
| * \brief | | | |
| * | | | |
| */ | | | |
| sockaddr_in RemoteAddress(); | | | |
| | | | |
| /** | | | |
| * \brief Get InetAddress. | | * \brief Get InetAddress. | |
| * | | * | |
| */ | | */ | |
| InetAddress * GetInetAddress(); | | InetAddress * GetInetAddress(); | |
| | | | |
| /** | | /** | |
| * \brief Get the local port. | | * \brief Get the local port. | |
| * | | * | |
| */ | | */ | |
| int GetLocalPort(); | | int GetLocalPort(); | |
| | | | |
End of changes. 6 change blocks. |
| 26 lines changed or deleted | | 10 lines changed or added | |
|
| jmenu.h | | jmenu.h | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
| #ifndef J_MENU_H | | #ifndef J_MENU_H | |
| #define J_MENU_H | | #define J_MENU_H | |
| | | | |
| #include "jframe.h" | | #include "jframe.h" | |
|
| #include "jframeinputlistener.h" | | | |
| #include "jimage.h" | | #include "jimage.h" | |
| #include "jmouselistener.h" | | #include "jmouselistener.h" | |
| #include "jitemcomponent.h" | | #include "jitemcomponent.h" | |
| #include "jthememanager.h" | | #include "jthememanager.h" | |
| | | | |
| #include <string> | | #include <string> | |
| #include <iostream> | | #include <iostream> | |
| #include <vector> | | #include <vector> | |
| | | | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| | | | |
| skipping to change at line 52 | | skipping to change at line 51 | |
| enum jmenu_align_t { | | enum jmenu_align_t { | |
| MENU_ALIGN, | | MENU_ALIGN, | |
| SUBMENU_ALIGN | | SUBMENU_ALIGN | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
|
| class Menu : public jgui::ItemComponent, public jgui::FrameInputListener, p
ublic jgui::ThemeListener{ | | class Menu : public KeyListener, public MouseListener, public jgui::ItemCom
ponent, public jgui::ThemeListener{ | |
| | | | |
| private: | | private: | |
| jthread::Mutex _menu_mutex; | | jthread::Mutex _menu_mutex; | |
| jthread::Condition _menu_sem; | | jthread::Condition _menu_sem; | |
| | | | |
| std::vector<Menu *> _menus; | | std::vector<Menu *> _menus; | |
| jgui::Frame *_frame; | | jgui::Frame *_frame; | |
|
| jgui::Image *prefetch; | | jgui::Image *_check; | |
| jmenu_align_t _menu_align; | | jmenu_align_t _menu_align; | |
| std::string _title; | | std::string _title; | |
| int _top_index, | | int _top_index, | |
| _item_size, | | _item_size, | |
| _visible_items; | | _visible_items; | |
| bool _centered_interaction; | | bool _centered_interaction; | |
| | | | |
| private: | | private: | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
|
| virtual void MousePressed(MouseEvent *event); | | virtual void KeyPressed(KeyEvent *event); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
|
| virtual void MouseReleased(MouseEvent *event); | | virtual void MousePressed(MouseEvent *event); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
|
| virtual void MouseClicked(MouseEvent *event); | | virtual void MouseReleased(MouseEvent *event); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual void MouseMoved(MouseEvent *event); | | virtual void MouseMoved(MouseEvent *event); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| | | | |
| skipping to change at line 278 | | skipping to change at line 277 | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual void Paint(Graphics *g); | | virtual void Paint(Graphics *g); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
|
| virtual void InputChanged(KeyEvent *event); | | | |
| | | | |
| /** | | | |
| * \brief | | | |
| * | | | |
| */ | | | |
| virtual void RegisterInputListener(FrameInputListener *liste | | | |
| ner); | | | |
| | | | |
| /** | | | |
| * \brief | | | |
| * | | | |
| */ | | | |
| virtual void RemoveInputListener(FrameInputListener *listene | | | |
| r); | | | |
| | | | |
| /** | | | |
| * \brief | | | |
| * | | | |
| */ | | | |
| virtual std::vector<FrameInputListener *> & GetFrameInputLis | | | |
| teners(); | | | |
| | | | |
| /** | | | |
| * \brief | | | |
| * | | | |
| */ | | | |
| virtual void ThemeChanged(ThemeEvent *event); | | virtual void ThemeChanged(ThemeEvent *event); | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 7 change blocks. |
| 33 lines changed or deleted | | 5 lines changed or added | |
|
| jmulticastsocket.h | | jmulticastsocket.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_MULTICAST_SOCKET_H | | #ifndef J_MULTICASTSOCKET_H | |
| #define J_MULTICAST_SOCKET_H | | #define J_MULTICASTSOCKET_H | |
| | | | |
| #include "jinetaddress.h" | | #include "jinetaddress.h" | |
| #include "jsocketoption.h" | | #include "jsocketoption.h" | |
| #include "jsocketinputstream.h" | | #include "jsocketinputstream.h" | |
| #include "jsocketoutputstream.h" | | #include "jsocketoutputstream.h" | |
| #include "jconnection.h" | | #include "jconnection.h" | |
| | | | |
| #include "jobject.h" | | #include "jobject.h" | |
| | | | |
| #include <iostream> | | #include <iostream> | |
| | | | |
| skipping to change at line 60 | | skipping to change at line 60 | |
| * \brief MulticastSocket. | | * \brief MulticastSocket. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class MulticastSocket : public jsocket::Connection{ | | class MulticastSocket : public jsocket::Connection{ | |
| | | | |
| private: | | private: | |
| /** \brief Use to bind the socket in a free port */ | | /** \brief Use to bind the socket in a free port */ | |
| static int _used_port; | | static int _used_port; | |
| | | | |
|
| #ifdef _WIN32 | | | |
| /** \brief Socket handler. */ | | /** \brief Socket handler. */ | |
|
| SOCKET _fds, _fdr; | | jsocket_t _fds, _fdr; | |
| #else | | | |
| /** \brief Descriptor */ | | | |
| int _fds, _fdr; | | | |
| #endif | | | |
| /** \brief Local socket */ | | /** \brief Local socket */ | |
|
| sockaddr_in _sock_s, _sock_r; | | struct sockaddr_in _sock_s, _sock_r; | |
| /** \brief Input stream */ | | /** \brief Input stream */ | |
| SocketInputStream *_is; | | SocketInputStream *_is; | |
| /** \brief Output stream */ | | /** \brief Output stream */ | |
| SocketOutputStream *_os; | | SocketOutputStream *_os; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _sent_bytes; | | int64_t _sent_bytes; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _receive_bytes; | | int64_t _receive_bytes; | |
| /** \brief */ | | /** \brief */ | |
| std::vector<std::string> _groups; | | std::vector<std::string> _groups; | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 112 | |
| * | | * | |
| */ | | */ | |
| MulticastSocket(std::string addr_, int port_, int rbuf_ = 65
535, int wbuf_ = 4096); | | MulticastSocket(std::string addr_, int port_, int rbuf_ = 65
535, int wbuf_ = 4096); | |
| | | | |
| /** | | /** | |
| * \brief Destrutor virtual. | | * \brief Destrutor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~MulticastSocket(); | | virtual ~MulticastSocket(); | |
| | | | |
|
| #ifdef _WIN32 | | /** | |
| virtual SOCKET GetHandler(); | | * \brief | |
| #else | | * | |
| virtual int GetHandler(); | | */ | |
| #endif | | virtual jsocket_t GetHandler(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::InputStream * GetInputStream(); | | virtual jio::InputStream * GetInputStream(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| | | | |
End of changes. 5 change blocks. |
| 14 lines changed or deleted | | 9 lines changed or added | |
|
| jserversocket.h | | jserversocket.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_SERVER_SOCKET_H | | #ifndef J_SERVERSOCKET_H | |
| #define J_SERVER_SOCKET_H | | #define J_SERVERSOCKET_H | |
| | | | |
|
| | | #include "jconnection.h" | |
| #include "jinetaddress.h" | | #include "jinetaddress.h" | |
| | | | |
|
| #include "jobject.h" | | | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| #include <windows.h> | | #include <windows.h> | |
| #include <winsock.h> | | #include <winsock.h> | |
| #else | | #else | |
| #include <sys/socket.h> | | #include <sys/socket.h> | |
| #endif | | #endif | |
| | | | |
| #include <stdint.h> | | #include <stdint.h> | |
| | | | |
| namespace jsocket { | | namespace jsocket { | |
| | | | |
| class Socket; | | class Socket; | |
| | | | |
| /** | | /** | |
| * \brief ServerSocket. | | * \brief ServerSocket. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class ServerSocket : public virtual jcommon::Object{ | | class ServerSocket : public virtual jcommon::Object{ | |
| | | | |
|
| private: | | private: | |
| #ifdef _WIN32 | | /** \brief Socket handler. */ | |
| /** \brief Socket handler. */ | | jsocket_t _fd; | |
| SOCKET _fd; | | /** \brief Local socket. */ | |
| #else | | struct sockaddr_in _lsock; | |
| /** \brief Socket handler. */ | | /** \brief Remote socket. */ | |
| int _fd; | | struct sockaddr_in _rsock; | |
| #endif | | /** \brief */ | |
| /** \brief Local socket. */ | | InetAddress *_local; | |
| sockaddr_in _lsock; | | /** \brief */ | |
| /** \brief Remote socket. */ | | | |
| sockaddr_in _rsock; | | | |
| /** \brief */ | | | |
| InetAddress *_local; | | | |
| /** \brief */ | | | |
| bool _is_closed; | | bool _is_closed; | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void CreateSocket(); | | void CreateSocket(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void BindSocket(InetAddress *, int); | | void BindSocket(InetAddress *, int); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void ListenSocket(int); | | void ListenSocket(int); | |
| | | | |
|
| public: | | public: | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| ServerSocket(int port, int backlog = 5, InetAddress * = NULL); | | ServerSocket(int port, int backlog = 5, InetAddress * = NULL | |
| | | ); | |
| | | | |
|
| /** | | /** | |
| * \brief Destructor virtual. | | * \brief Destructor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~ServerSocket(); | | virtual ~ServerSocket(); | |
| | | | |
|
| /** | | /** | |
| * \brief Accept a new socket. | | * \brief Accept a new socket. | |
| * | | * | |
| */ | | */ | |
| Socket * Accept(); | | Socket * Accept(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| InetAddress * GetInetAddress(); | | InetAddress * GetInetAddress(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the local port. | | * \brief Get the local port. | |
| * | | * | |
| */ | | */ | |
| int GetLocalPort(); | | int GetLocalPort(); | |
| | | | |
|
| /** | | /** | |
| * \brief Close the server socket. | | * \brief Close the server socket. | |
| * | | * | |
| */ | | */ | |
| void Close(); | | void Close(); | |
| | | | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 13 change blocks. |
| 65 lines changed or deleted | | 60 lines changed or added | |
|
| jsocket.h | | jsocket.h | |
| | | | |
| skipping to change at line 57 | | skipping to change at line 57 | |
| /** | | /** | |
| * \brief Socket. | | * \brief Socket. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class Socket : public jsocket::Connection{ | | class Socket : public jsocket::Connection{ | |
| | | | |
| friend class ServerSocket; //Socket * ServerSocket::Accept(); | | friend class ServerSocket; //Socket * ServerSocket::Accept(); | |
| | | | |
| private: | | private: | |
|
| #ifdef _WIN32 | | | |
| /** \brief Socket handler. */ | | | |
| SOCKET _fd; | | | |
| #else | | | |
| /** \brief Socket handler. */ | | /** \brief Socket handler. */ | |
|
| int _fd; | | jsocket_t _fd; | |
| #endif | | | |
| /** \brief */ | | /** \brief */ | |
| SocketInputStream *_is; | | SocketInputStream *_is; | |
| /** \brief */ | | /** \brief */ | |
| SocketOutputStream *_os; | | SocketOutputStream *_os; | |
| /** \brief */ | | /** \brief */ | |
|
| sockaddr_in _lsock; | | struct sockaddr_in _lsock; | |
| /** \brief */ | | /** \brief */ | |
|
| sockaddr_in _server_sock; | | struct sockaddr_in _server_sock; | |
| /** \brief */ | | /** \brief */ | |
| InetAddress *_address; | | InetAddress *_address; | |
| /** \brief Bytes sent. */ | | /** \brief Bytes sent. */ | |
| int64_t _sent_bytes; | | int64_t _sent_bytes; | |
| /** \brief Bytes received. */ | | /** \brief Bytes received. */ | |
| int64_t _receive_bytes; | | int64_t _receive_bytes; | |
| /** \brief */ | | /** \brief */ | |
| int _timeout; | | int _timeout; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 105 | | skipping to change at line 100 | |
| * | | * | |
| */ | | */ | |
| void ConnectSocket(InetAddress *, int); | | void ConnectSocket(InetAddress *, int); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void InitStreams(int64_t rbuf_, int64_t wbuf_); | | void InitStreams(int64_t rbuf_, int64_t wbuf_); | |
| | | | |
|
| public: | | protected: | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
|
| Socket(int handler_, sockaddr_in server_, int timeout_ = 0,
int rbuf_ = 65535, int wbuf_ = 4096); | | Socket(jsocket_t handler_, struct sockaddr_in server_, int t
imeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
|
| | | public: | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| Socket(InetAddress *addr_, int port_, int timeout_ = 0, int
rbuf_ = 65535, int wbuf_ = 4096); | | Socket(InetAddress *addr_, int port_, int timeout_ = 0, int
rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 138 | |
| * | | * | |
| */ | | */ | |
| Socket(std::string host_, int port_, InetAddress *local_addr
_, int local_port_, int timeout_ = 0, int rbuf_ = 4096, int wbuf_ = 4096); | | Socket(std::string host_, int port_, InetAddress *local_addr
_, int local_port_, int timeout_ = 0, int rbuf_ = 4096, int wbuf_ = 4096); | |
| | | | |
| /** | | /** | |
| * \brief Destrutor virtual. | | * \brief Destrutor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~Socket(); | | virtual ~Socket(); | |
| | | | |
|
| #ifdef _WIN32 | | /** | |
| virtual SOCKET GetHandler(); | | * \brief | |
| #else | | * | |
| virtual int GetHandler(); | | */ | |
| #endif | | virtual jsocket_t GetHandler(); | |
| | | | |
| /** | | /** | |
| * \brief Send bytes to a destination. | | * \brief Send bytes to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual int Send(const char *b_, int size_, bool block_ = tr
ue); | | virtual int Send(const char *b_, int size_, bool block_ = tr
ue); | |
| | | | |
| /** | | /** | |
| * \brief Send bytes to a destination waiting a timeout. | | * \brief Send bytes to a destination waiting a timeout. | |
| * | | * | |
| | | | |
End of changes. 8 change blocks. |
| 15 lines changed or deleted | | 11 lines changed or added | |
|
| jsocketinputstream.h | | jsocketinputstream.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_SOCKET_INPUT_STREAM_H | | #ifndef J_SOCKETINPUTSTREAM_H | |
| #define J_SOCKET_INPUT_STREAM_H | | #define J_SOCKETINPUTSTREAM_H | |
| | | | |
| #include "jobject.h" | | #include "jobject.h" | |
| #include "jinputstream.h" | | #include "jinputstream.h" | |
| #include "jconnection.h" | | #include "jconnection.h" | |
| | | | |
| #include <stdexcept> | | #include <stdexcept> | |
| #include <string> | | #include <string> | |
| #include <cstring> | | #include <cstring> | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 48 | |
| namespace jsocket { | | namespace jsocket { | |
| | | | |
| /** | | /** | |
| * \brief SocketInputStream. | | * \brief SocketInputStream. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class SocketInputStream : public jio::InputStream{ | | class SocketInputStream : public jio::InputStream{ | |
| | | | |
| private: | | private: | |
|
| #ifdef _WIN32 | | | |
| /** \brief */ | | /** \brief */ | |
|
| SOCKET _fd; | | jsocket_t _fd; | |
| #else | | | |
| /** \brief */ | | | |
| int _fd; | | | |
| #endif | | | |
| /** \brief */ | | /** \brief */ | |
| Connection *_connection; | | Connection *_connection; | |
| /** \brief */ | | /** \brief */ | |
|
| | | struct sockaddr *_address; | |
| | | /** \brief */ | |
| char *_buffer; | | char *_buffer; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _buffer_length; | | int64_t _buffer_length; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _current_index; | | int64_t _current_index; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _end_index; | | int64_t _end_index; | |
| /** \brief */ | | /** \brief */ | |
| int64_t _receive_bytes; | | int64_t _receive_bytes; | |
| /** \brief */ | | /** \brief */ | |
|
| sockaddr_in _server_sock; | | | |
| /** \brief */ | | | |
| bool *_is_closed; | | bool *_is_closed; | |
| /** \brief */ | | /** \brief */ | |
| bool _stream; | | bool _stream; | |
| | | | |
| public: | | public: | |
| /** | | /** | |
| * \brief Construtor. | | * \brief Construtor. | |
| * | | * | |
| */ | | */ | |
| SocketInputStream(Connection *conn_, bool *is_closed
_, int64_t size_ = 65535LL); | | SocketInputStream(Connection *conn_, bool *is_closed
_, int64_t size_ = 65535LL); | |
| | | | |
| /** | | /** | |
| * \brief Construtor. | | * \brief Construtor. | |
| * | | * | |
| */ | | */ | |
|
| SocketInputStream(Connection *conn_, bool *is_closed
_, sockaddr_in server_sock_, int64_t size_ = 65535LL); | | SocketInputStream(Connection *conn_, bool *is_closed
_, struct sockaddr *address_, int64_t size_ = 65535LL); | |
| | | | |
| /** | | /** | |
| * \brief Destrutor virtual. | | * \brief Destrutor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~SocketInputStream(); | | virtual ~SocketInputStream(); | |
| | | | |
| /** | | /** | |
| * \brief jio::InputStream | | * \brief jio::InputStream | |
| * | | * | |
| | | | |
End of changes. 6 change blocks. |
| 11 lines changed or deleted | | 6 lines changed or added | |
|
| jsocketoption.h | | jsocketoption.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_SOCKET_OPTION_H | | #ifndef J_SOCKETOPTION_H | |
| #define J_SOCKET_OPTION_H | | #define J_SOCKETOPTION_H | |
| | | | |
| #include "jconnection.h" | | #include "jconnection.h" | |
| | | | |
| #include <string> | | #include <string> | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| #include <windows.h> | | #include <windows.h> | |
| #else | | #else | |
| #include <sys/socket.h> | | #include <sys/socket.h> | |
|
| | | #include <netinet/in.h> | |
| #endif | | #endif | |
| | | | |
| namespace jsocket { | | namespace jsocket { | |
| | | | |
| class Socket; | | class Socket; | |
|
| class SSLSocket; | | class Socket6; | |
| class DatagramSocket; | | class DatagramSocket; | |
|
| | | class DatagramSocket6; | |
| | | class SSLSocket; | |
| | | class SSLSocket6; | |
| | | class MulticastSocket; | |
| | | class MulticastSocket6; | |
| | | class LocalSocket; | |
| | | class LocalDatagramSocket; | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| enum socket_shutdown_t { | | enum socket_shutdown_t { | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
|
| SHUTDOWN_READ = 0, | | SHUTDOWN_READ = 0, | |
| SHUTDOWN_WRITE = 1, | | SHUTDOWN_WRITE = 1, | |
| SHUTDOWN_READ_WRITE = 2 | | SHUTDOWN_READ_WRITE = 2 | |
| #else | | #else | |
|
| SHUTDOWN_READ = SHUT_RD, | | SHUTDOWN_READ = SHUT_RD, | |
| SHUTDOWN_WRITE = SHUT_WR, | | SHUTDOWN_WRITE = SHUT_WR, | |
| SHUTDOWN_READ_WRITE = SHUT_RDWR | | SHUTDOWN_READ_WRITE = SHUT_RDWR | |
| #endif | | #endif | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * \brief SocketOptions. | | * \brief SocketOptions. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class SocketOption : public virtual jcommon::Object{ | | class SocketOption : public virtual jcommon::Object{ | |
|
| #ifdef _WIN32 | | | |
| #else | | | |
| friend class SSLSocket; | | | |
| #endif | | | |
| | | | |
|
| friend class Socket; | | friend class Socket; | |
| friend class DatagramSocket; | | friend class Socket6; | |
| friend class RawSocket; | | friend class DatagramSocket; | |
| friend class MulticastSocket; | | friend class DatagramSocket6; | |
| friend class SocketPipe; | | friend class SSLSocket; | |
| friend class PromiscSocket; | | friend class SSLSocket6; | |
| | | friend class MulticastSocket; | |
| | | friend class MulticastSocket6; | |
| | | friend class RawSocket; | |
| | | friend class SocketPipe; | |
| | | friend class PromiscSocket; | |
| | | friend class LocalSocket; | |
| | | friend class LocalDatagramSocket; | |
| | | | |
|
| private: | | private: | |
| #ifdef _WIN32 | | /** \brief Socket handler. */ | |
| /** \brief Socket handler. */ | | jsocket_t _fd; | |
| SOCKET _fd; | | /** \brief Type of socket */ | |
| #else | | jconnection_type_t _type; | |
| /** \brief Socket handler. */ | | | |
| int _fd; | | | |
| #endif | | | |
| /** \brief Type of socket */ | | | |
| jconnection_type_t _type; | | | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| #ifdef _WIN32 | | SocketOption(jsocket_t fd_, jconnection_type_t type_); | |
| SocketOption(SOCKET fd_, jconnection_type_t type_); | | | |
| #else | | | |
| SocketOption(int fd_, jconnection_type_t type_); | | | |
| #endif | | | |
| | | | |
|
| public: | | public: | |
| /** | | /** | |
| * \brief Virtual destructor | | * \brief Virtual destructor | |
| * | | * | |
| */ | | */ | |
| virtual ~SocketOption(); | | virtual ~SocketOption(); | |
| | | | |
|
| /** | | /** | |
| * \brief Enable sending of keep-alive messages on connection-orien | | * \brief Enable sending of keep-alive messages on connectio | |
| ted sockets. | | n-oriented sockets. | |
| * | | * | |
| */ | | */ | |
| void SetKeepAlive(bool b_); | | void SetKeepAlive(bool b_); | |
| | | | |
|
| /** | | /** | |
| * \brief If this option is enabled, out-of-band data is directly p | | * \brief If this option is enabled, out-of-band data is dir | |
| laced into the receive data stream. | | ectly placed into the receive data stream. | |
| * Otherwise out-of-band data is only passed when the MSG_OOB flag | | * Otherwise out-of-band data is only passed when the MSG_OO | |
| is set during receiving. | | B flag is set during receiving. | |
| * | | * | |
| */ | | */ | |
| void SetOutOfBandInLine(bool b_); | | void SetOutOfBandInLine(bool b_); | |
| | | | |
|
| /** | | /** | |
| * \brief Specify the sending or receiving timeouts until reporting | | * \brief Specify the sending or receiving timeouts until re | |
| an error. | | porting an error. | |
| * They are fixed to a protocol specific setting in Linux an | | * They are fixed to a protocol specific setting in L | |
| d cannot be read or written. | | inux and cannot be read or written. | |
| * | | * | |
| */ | | */ | |
| void SetSendTimeout(int time_); | | void SetSendTimeout(int time_); | |
| | | | |
|
| /** | | /** | |
| * \brief Specify the sending or receiving timeouts until reporting | | * \brief Specify the sending or receiving timeouts until re | |
| an error. | | porting an error. | |
| * They are fixed to a protocol specific setting in Linux an | | * They are fixed to a protocol specific setting in L | |
| d cannot be read or written. | | inux and cannot be read or written. | |
| * | | * | |
| */ | | */ | |
| void SetReceiveTimeout(int time_); | | void SetReceiveTimeout(int time_); | |
| | | | |
|
| /** | | /** | |
| * \brief Enable or disable the receiving of the SCM_CREDENTIALS co | | * \brief Enable or disable the receiving of the SCM_CREDENT | |
| ntrol message. | | IALS control message. | |
| * | | * | |
| */ | | */ | |
| void SetPassCredentials(bool opt_); | | void SetPassCredentials(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Return the credentials of the foreign process connec | | * \brief Return the credentials of the foreign process | |
| ted to this socket. | | connected to this socket. | |
| * | | * | |
| */ | | */ | |
| void GetPeerCredentials(void *opt); | | void GetPeerCredentials(void *opt); | |
| | | | |
|
| /** | | /** | |
| * \brief Bind this socket to a particular device like "eth0", as s | | * \brief Bind this socket to a particular device like "eth0 | |
| pecified in the passed | | ", as specified in the passed | |
| * interface name. If the name is an empty string or the option | | * interface name. If the name is an empty string or the | |
| length is zero, | | option length is zero, | |
| * the socket device binding is removed. | | * the socket device binding is removed. | |
| * | | * | |
| */ | | */ | |
| void BindToDevice(std::string dev_); | | void BindToDevice(std::string dev_); | |
| | | | |
|
| /** | | /** | |
| * \brief Indicates that the rules used in validating addresses sup | | * \brief Indicates that the rules used in validating addres | |
| plied in a bind call | | ses supplied in a bind call | |
| * should allow reuse of local addresses. For PF_INET sockets | | * should allow reuse of local addresses. For PF_INET s | |
| this means that a socket | | ockets this means that a socket | |
| * may bind, except when there is an active listening socket bound | | * may bind, except when there is an active listening socket | |
| to the address. When | | bound to the address. When | |
| * the listening socket is bound to INADDR_ANY with a specific port | | * the listening socket is bound to INADDR_ANY with a specif | |
| then it is not possible | | ic port then it is not possible | |
| * to bind to this port for any local address. | | * to bind to this port for any local address. | |
| * | | * | |
| */ | | */ | |
| void SetReuseAddress(bool opt_); | | void SetReuseAddress(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void SetReusePort(bool opt_); | | void SetReusePort(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Gets the socket type | | * \brief Gets the socket type | |
| * | | * | |
| */ | | */ | |
| virtual jconnection_type_t GetType(); | | virtual jconnection_type_t GetType(); | |
| | | | |
|
| /** | | /** | |
| * \brief Returns a value indicating whether or not this socket has | | * \brief Returns a value indicating whether or not this soc | |
| been marked to accept | | ket has been marked to accept | |
| * connections with listen. | | * connections with listen. | |
| * | | * | |
| */ | | */ | |
| bool GetSocketAcceptConnection(); | | bool GetSocketAcceptConnection(); | |
| | | | |
|
| /** | | /** | |
| * \brief Don't send via a gateway, only send to directly connecte | | * \brief Don't send via a gateway, only send to directly c | |
| d hosts. | | onnected hosts. | |
| * | | * | |
| */ | | */ | |
| void SetRoute(bool opt_); | | void SetRoute(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Set or get the broadcast flag. When enabled, datagram soc | | * \brief Set or get the broadcast flag. When enabled, datag | |
| kets receive packets | | ram sockets receive packets | |
| * sent to a broadcast address and they are allowed to send p | | * sent to a broadcast address and they are allowed to | |
| ackets to a broadcast | | send packets to a broadcast | |
| * address. This option has no effect on stream-oriented sockets. | | * address. This option has no effect on stream-oriented soc | |
| * | | kets. | |
| */ | | * | |
| void SetBroadcast(bool opt_); | | */ | |
| | | void SetBroadcast(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void SetNoDelay(bool b_); | | void SetNoDelay(bool b_); | |
| | | | |
|
| /** | | /** | |
| * \brief Sets or gets the maximum socket send buffer in bytes | | * \brief Sets or gets the maximum socket send buffer in byt | |
| * | | es | |
| */ | | * | |
| void SetSendMaximumBuffer(int length_); | | */ | |
| | | void SetSendMaximumBuffer(int length_); | |
| | | | |
|
| /** | | /** | |
| * \brief Sets or gets the maximum socket receive buffer in bytes. | | * \brief Sets or gets the maximum socket receive buffer in | |
| * | | bytes. | |
| */ | | * | |
| void SetReceiveMaximumBuffer(int length_); | | */ | |
| | | void SetReceiveMaximumBuffer(int length_); | |
| | | | |
|
| /** | | /** | |
| * \brief Sets or gets the maximum socket send buffer in bytes. | | * \brief Sets or gets the maximum socket send buffer in byt | |
| * | | es. | |
| */ | | * | |
| int GetSendMaximumBuffer(); | | */ | |
| | | int GetSendMaximumBuffer(); | |
| | | | |
|
| /** | | /** | |
| * \brief Sets or gets the maximum socket receive buffer in bytes. | | * \brief Sets or gets the maximum socket receive buffer in | |
| * | | bytes. | |
| */ | | * | |
| int GetReceiveMaximumBuffer(); | | */ | |
| | | int GetReceiveMaximumBuffer(); | |
| | | | |
|
| /** | | /** | |
| * \brief When enabled, a close() or shutdown() will not return unt | | * \brief When enabled, a close() or shutdown() will not ret | |
| il all queued messages | | urn until all queued messages | |
| * for the socket have been successfully sent or the linger time | | * for the socket have been successfully sent or the ling | |
| out has been reached. | | er timeout has been reached. | |
| * Otherwise, the call returns immediately and the closing is done | | * Otherwise, the call returns immediately and the closing i | |
| in the background. | | s done in the background. | |
| * When the socket is closed as part of exit(), it always lingers | | * When the socket is closed as part of exit(), it always | |
| in the background. | | lingers in the background. | |
| * | | * | |
| */ | | */ | |
| void SetLinger(bool on_, int linger_); | | void SetLinger(bool on_, int linger_); | |
| | | | |
|
| /** | | /** | |
| * \brief Set the protocol-defined priority for all packets to be s | | * \brief Set the protocol-defined priority for all packets | |
| ent on this socket. | | to be sent on this socket. | |
| * Linux uses this value to order the networking queues: | | * Linux uses this value to order the networking queues: | |
| * packets with a higher priority may be processed first depending | | * packets with a higher priority may be processed first dep | |
| on the selected device | | ending on the selected device | |
| * queueing discipline. | | * queueing discipline. | |
| * | | * | |
| */ | | */ | |
| void SetPriority(int opt_); | | void SetPriority(int opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Get and clear the pending socket error. | | * \brief Get and clear the pending socket error. | |
| * | | * | |
| */ | | */ | |
| void ClearPendingSocketError(); | | void ClearPendingSocketError(); | |
| | | | |
|
| /** | | /** | |
| * \brief /usr/include/linux/ip.h | | * \brief /usr/include/linux/ip.h | |
| * | | * | |
| */ | | */ | |
| void SetTypeOfService(int type_); | | void SetTypeOfService(int type_); | |
| | | | |
|
| /** | | /** | |
| * \brief Throw signal EAGAIN set timeoutexception exception. | | * \brief Throw signal EAGAIN set timeoutexception exception | |
| * | | . | |
| */ | | * | |
| void SetBlocking(bool opt_); | | */ | |
| | | void SetBlocking(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Set TTL | | * \brief Set TTL | |
| * | | * | |
| */ | | */ | |
| void SetTimeToLive(int opt_); | | void SetTimeToLive(int opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Header is included ? | | * \brief Header is included ? | |
| * | | * | |
| */ | | */ | |
| void SetHeaderInclude(bool opt_); | | void SetHeaderInclude(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief Return the receive timestamp of the last packet passed to | | * \brief Return the receive timestamp of the last packet pa | |
| the user. | | ssed to the user. | |
| * This is useful for accurate round trip time measurements. | | * This is useful for accurate round trip time measurements. | |
| * | | * | |
| */ | | */ | |
| int64_t GetTimeStamp(); | | int64_t GetTimeStamp(); | |
| | | | |
| /** | | /** | |
| * \brief Get MTU. | | * \brief Get MTU. | |
| * | | * | |
| */ | | */ | |
| int GetMaximunTransferUnit(); | | int GetMaximunTransferUnit(); | |
| | | | |
|
| /** | | /** | |
| * \brief Change the O_ASYNC flag to enable or disable asynchronous | | * \brief Change the O_ASYNC flag to enable or disable async | |
| IO mode of the socket. | | hronous IO mode of the socket. | |
| * Asynchronous IO mode means that the SIGIO signal or the signal s | | * Asynchronous IO mode means that the SIGIO signal or the s | |
| et with F_SETSIG is raised | | ignal set with F_SETSIG is raised | |
| * when a new I/O event occurs. | | * when a new I/O event occurs. | |
| * | | * | |
| */ | | */ | |
| void SetIOAsync(bool opt_); | | void SetIOAsync(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void SetMulticastLoop(bool opt_); | | void SetMulticastLoop(bool opt_); | |
| | | | |
|
| /** | | /** | |
| * \brief -1 enabled nomal multicast forwarding | | * \brief -1 enabled nomal multicast forwarding | |
| * | | * | |
| */ | | */ | |
| void SetRSVP(int opt_); | | void SetRSVP(int opt_); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void SetShutdown(socket_shutdown_t opt_); | | void SetShutdown(socket_shutdown_t opt_); | |
|
| | | | |
| | | /** | |
| | | * \brief | |
| | | * | |
| | | */ | |
| | | void SetIPv6UnicastHops(int opt_); | |
| | | | |
| | | /** | |
| | | * \brief | |
| | | * | |
| | | */ | |
| | | int GetIPv6UnicastHops(); | |
| | | | |
| | | /** | |
| | | * \brief | |
| | | * | |
| | | */ | |
| | | void SetIPv6Only(bool opt_); | |
| | | | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 41 change blocks. |
| 236 lines changed or deleted | | 263 lines changed or added | |
|
| jsocketoutputstream.h | | jsocketoutputstream.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_SOCKET_OUTPUT_STREAM_H | | #ifndef J_SOCKETOUTPUTSTREAM_H | |
| #define J_SOCKET_OUTPUT_STREAM_H | | #define J_SOCKETOUTPUTSTREAM_H | |
| | | | |
| #include "joutputstream.h" | | #include "joutputstream.h" | |
| #include "jconnection.h" | | #include "jconnection.h" | |
| | | | |
| #include <stdexcept> | | #include <stdexcept> | |
| #include <string> | | #include <string> | |
| #include <cstring> | | #include <cstring> | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| #include <windows.h> | | #include <windows.h> | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 47 | |
| | | | |
| namespace jsocket { | | namespace jsocket { | |
| | | | |
| /** | | /** | |
| * \brief SocketOutputStream. | | * \brief SocketOutputStream. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class SocketOutputStream : public jio::OutputStream{ | | class SocketOutputStream : public jio::OutputStream{ | |
| | | | |
|
| private: | | private: | |
| #ifdef _WIN32 | | /** \brief */ | |
| SOCKET _fd; | | jsocket_t _fd; | |
| #else | | /** \brief */ | |
| int _fd; | | struct sockaddr *_address; | |
| #endif | | /** \brief */ | |
| /** \brief */ | | char *_buffer; | |
| char *_buffer; | | /** \brief */ | |
| /** \brief */ | | int64_t _buffer_length; | |
| int64_t _buffer_length; | | /** \brief */ | |
| /** \brief */ | | int64_t _current_index; | |
| int64_t _current_index; | | /** \brief */ | |
| /** \brief */ | | int64_t _sent_bytes; | |
| int64_t _sent_bytes; | | /** \brief */ | |
| /** \brief */ | | bool _stream; | |
| bool _stream; | | /** \brief */ | |
| /** \brief */ | | bool *_is_closed; | |
| sockaddr_in _server_sock; | | /** \brief */ | |
| /** \brief */ | | Connection *_connection; | |
| bool *_is_closed; | | | |
| /** \brief */ | | | |
| Connection *_connection; | | | |
| | | | |
|
| public: | | public: | |
| /** | | /** | |
| * \brief Construtor. | | * \brief Construtor. | |
| * | | * | |
| */ | | */ | |
| SocketOutputStream(Connection *conn_, bool *is_close | | SocketOutputStream(Connection *conn_, bool *is_closed, int64 | |
| d, int64_t size_ = 4096LL); | | _t size_ = 4096LL); | |
| | | | |
|
| /** | | /** | |
| * \brief Construtor. | | * \brief Construtor. | |
| * | | * | |
| */ | | */ | |
| SocketOutputStream(Connection *conn_, bool *is_close | | SocketOutputStream(Connection *conn_, bool *is_closed, struc | |
| d, sockaddr_in server_sock_, int64_t size_ = 65535LL); | | t sockaddr *address_, int64_t size_ = 65535LL); | |
| | | | |
|
| /** | | /** | |
| * \brief Destrutor virtual. | | * \brief Destrutor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~SocketOutputStream(); | | virtual ~SocketOutputStream(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual bool IsEmpty(); | | virtual bool IsEmpty(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t Available(); | | virtual int64_t Available(); | |
| | | | |
|
| /** | | /** | |
| * \brief jio::OutputStream | | * \brief jio::OutputStream | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetSize(); | | virtual int64_t GetSize(); | |
| | | | |
|
| /** | | /** | |
| * \brief jio::OutputStream | | * \brief jio::OutputStream | |
| * | | * | |
| */ | | */ | |
| virtual void Seek(int64_t index); | | virtual void Seek(int64_t index); | |
| | | | |
|
| /** | | /** | |
| * \brief jio::OutputStream | | * \brief jio::OutputStream | |
| * | | * | |
| */ | | */ | |
| virtual void Close(); | | virtual void Close(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t Write(int64_t c_); | | virtual int64_t Write(int64_t c_); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t Write(const char *data_, int64_t dat | | virtual int64_t Write(const char *data_, int64_t data_length | |
| a_length_); | | _); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetAvailable(); | | virtual int64_t GetAvailable(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetSentBytes(); | | virtual int64_t GetSentBytes(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int64_t Flush(); | | virtual int64_t Flush(); | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 15 change blocks. |
| 93 lines changed or deleted | | 90 lines changed or added | |
|
| jsslserversocket.h | | jsslserversocket.h | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| * This program is distributed in the hope that it will be useful,
* | | * This program is distributed in the hope that it will be useful,
* | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
* | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* | |
| * GNU General Public License for more details.
* | | * GNU General Public License for more details.
* | |
| *
* | | *
* | |
| * You should have received a copy of the GNU General Public License
* | | * You should have received a copy of the GNU General Public License
* | |
| * along with this program; if not, write to the
* | | * along with this program; if not, write to the
* | |
| * Free Software Foundation, Inc.,
* | | * Free Software Foundation, Inc.,
* | |
| * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
|
| #ifndef J_SSL_SERVER_SOCKET_H | | #ifndef J_SSLSERVERSOCKET_H | |
| #define J_SSL_SERVER_SOCKET_H | | #define J_SSLSERVERSOCKET_H | |
| | | | |
| #include "jsslsocket.h" | | #include "jsslsocket.h" | |
| #include "jinetaddress.h" | | #include "jinetaddress.h" | |
| #include "jobject.h" | | #include "jobject.h" | |
| | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| #include <windows.h> | | #include <windows.h> | |
| #include <winsock.h> | | #include <winsock.h> | |
| #else | | #else | |
| #include <sys/socket.h> | | #include <sys/socket.h> | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 47 | |
| | | | |
| class SSLSocket; | | class SSLSocket; | |
| | | | |
| /** | | /** | |
| * \brief ServerSocket. | | * \brief ServerSocket. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class SSLServerSocket : public virtual jcommon::Object{ | | class SSLServerSocket : public virtual jcommon::Object{ | |
| | | | |
|
| private: | | private: | |
| #ifdef _WIN32 | | /** \brief Socket handler. */ | |
| /** \brief Socket handler. */ | | jsocket_t _fd; | |
| SOCKET _fd; | | /** \brief Local socket. */ | |
| #else | | sockaddr_in _lsock; | |
| /** \brief Socket handler. */ | | /** \brief Remote socket. */ | |
| int _fd; | | sockaddr_in _rsock; | |
| #endif | | /** \brief */ | |
| /** \brief Local socket. */ | | InetAddress *_local; | |
| sockaddr_in _lsock; | | /** \brief */ | |
| /** \brief Remote socket. */ | | | |
| sockaddr_in _rsock; | | | |
| /** \brief */ | | | |
| InetAddress *_local; | | | |
| /** \brief */ | | | |
| bool _is_closed; | | bool _is_closed; | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void CreateSocket(); | | void CreateSocket(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void BindSocket(InetAddress *, int); | | void BindSocket(InetAddress *, int); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void ListenSocket(int); | | void ListenSocket(int); | |
| | | | |
| /** | | /** | |
| * Create new CTX if none is available | | * Create new CTX if none is available | |
| * | | * | |
| */ | | */ | |
| virtual bool CheckContext(); | | virtual bool CheckContext(); | |
| | | | |
| /** | | /** | |
| * Create temp cert if no other is loaded | | * Create temp cert if no other is loaded | |
| * | | * | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 124 | |
| SSL_CTX *ctx; | | SSL_CTX *ctx; | |
| /** \brief SSL data */ | | /** \brief SSL data */ | |
| SSL *ssl; | | SSL *ssl; | |
| /** \brief Indicate CERT loaded or created */ | | /** \brief Indicate CERT loaded or created */ | |
| bool have_cert; | | bool have_cert; | |
| /** \brief keysize argument from constructor */ | | /** \brief keysize argument from constructor */ | |
| int rsa_keysize; | | int rsa_keysize; | |
| /** \brief userdata */ | | /** \brief userdata */ | |
| char *ud; | | char *ud; | |
| | | | |
|
| public: | | public: | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| SSLServerSocket(int port, int backlog = 5, int keysize = RSA_KEYSIZ | | SSLServerSocket(int port, int backlog = 5, int keysize = RSA | |
| E, InetAddress * = NULL); | | _KEYSIZE, InetAddress * = NULL); | |
| | | | |
|
| /** | | /** | |
| * \brief Destructor virtual. | | * \brief Destructor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~SSLServerSocket(); | | virtual ~SSLServerSocket(); | |
| | | | |
|
| /** | | /** | |
| * \brief Accept a new socket. | | * \brief Accept a new socket. | |
| * | | * | |
| */ | | */ | |
| SSLSocket * Accept(); | | SSLSocket * Accept(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| InetAddress * GetInetAddress(); | | InetAddress * GetInetAddress(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the local port. | | * \brief Get the local port. | |
| * | | * | |
| */ | | */ | |
| int GetLocalPort(); | | int GetLocalPort(); | |
| | | | |
|
| /** | | /** | |
| * \brief Close the server socket. | | * \brief Close the server socket. | |
| * | | * | |
| */ | | */ | |
| void Close(); | | void Close(); | |
| | | | |
| /** | | /** | |
| * Create temp cert if no other is loaded | | * Create temp cert if no other is loaded | |
| * | | * | |
| */ | | */ | |
| bool UseCertPassword(const char *cert_file, const char *priv
ate_key_file, std::string password); | | bool UseCertPassword(const char *cert_file, const char *priv
ate_key_file, std::string password); | |
| | | | |
| /** | | /** | |
| * Create temp cert if no other is loaded | | * Create temp cert if no other is loaded | |
| * | | * | |
| | | | |
End of changes. 11 change blocks. |
| 64 lines changed or deleted | | 59 lines changed or added | |
|
| jsslsocket.h | | jsslsocket.h | |
| | | | |
| skipping to change at line 74 | | skipping to change at line 74 | |
| | | | |
| class ServerSocket; | | class ServerSocket; | |
| | | | |
| /** | | /** | |
| * \brief Socket. | | * \brief Socket. | |
| * | | * | |
| * \author Jeff Ferr | | * \author Jeff Ferr | |
| */ | | */ | |
| class SSLSocket : public jsocket::Connection{ | | class SSLSocket : public jsocket::Connection{ | |
| | | | |
|
| friend class SSLServerSocket; //Socket * ServerSocket::Accept(); | | friend class SSLServerSocket; //Socket * ServerSocket::Accept(); | |
| | | | |
|
| private: | | private: | |
| #ifdef _WIN32 | | /** \brief Socket handler. */ | |
| /** \brief Socket handler. */ | | jsocket_t _fd; | |
| SOCKET _fd; | | /** \brief */ | |
| #else | | SSLSocketInputStream *_is; | |
| /** \brief Socket handler. */ | | /** \brief */ | |
| int _fd; | | SSLSocketOutputStream *_os; | |
| #endif | | /** \brief */ | |
| /** \brief */ | | sockaddr_in _lsock; | |
| SSLSocketInputStream *_is; | | /** \brief */ | |
| /** \brief */ | | sockaddr_in _server_sock; | |
| SSLSocketOutputStream *_os; | | /** \brief */ | |
| /** \brief */ | | InetAddress *_address; | |
| sockaddr_in _lsock; | | /** \brief Bytes sent. */ | |
| /** \brief */ | | int64_t _sent_bytes; | |
| sockaddr_in _server_sock; | | /** \brief Bytes received. */ | |
| /** \brief */ | | int64_t _receive_bytes; | |
| InetAddress *_address; | | /** \brief */ | |
| /** \brief Bytes sent. */ | | | |
| int64_t _sent_bytes; | | | |
| /** \brief Bytes received. */ | | | |
| int64_t _receive_bytes; | | | |
| /** \brief */ | | | |
| int _timeout; | | int _timeout; | |
| | | | |
|
| /** | | /** | |
| * \brief Create a new socket. | | * \brief Create a new socket. | |
| * | | * | |
| */ | | */ | |
| void CreateSocket(); | | void CreateSocket(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void BindSocket(InetAddress *, int); | | void BindSocket(InetAddress *, int); | |
| | | | |
|
| /** | | /** | |
| * \brief Connect the socket. | | * \brief Connect the socket. | |
| * | | * | |
| */ | | */ | |
| void ConnectSocket(InetAddress *, int); | | void ConnectSocket(InetAddress *, int); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void InitStreams(int rbuf, int wbuf); | | void InitStreams(int rbuf, int wbuf); | |
| | | | |
| /** | | /** | |
| * Create new CTX if none is available | | * Create new CTX if none is available | |
| * | | * | |
| */ | | */ | |
| virtual bool CheckContext(); | | virtual bool CheckContext(); | |
| | | | |
| /** | | /** | |
| * Create temp cert if no other is loaded | | * Create temp cert if no other is loaded | |
| * | | * | |
| | | | |
| skipping to change at line 161 | | skipping to change at line 156 | |
| /** \brief SSL data */ | | /** \brief SSL data */ | |
| SSL *ssl; | | SSL *ssl; | |
| | | | |
| /** \brief Indicate CERT loaded or created */ | | /** \brief Indicate CERT loaded or created */ | |
| bool have_cert; | | bool have_cert; | |
| /** \brief keysize argument from constructor */ | | /** \brief keysize argument from constructor */ | |
| int rsa_keysize; | | int rsa_keysize; | |
| /** \brief userdata */ | | /** \brief userdata */ | |
| char *ud; | | char *ud; | |
| | | | |
|
| public: | | private: | |
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
|
| SSLSocket(int handler_, sockaddr_in server_, int keysize = RSA_KEYS
IZE, int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | | SSLSocket(int handler_, struct sockaddr_in server_, int keys
ize = RSA_KEYSIZE, int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
|
| /** | | public: | |
| * \brief Constructor. | | /** | |
| * | | * \brief Constructor. | |
| */ | | * | |
| SSLSocket(InetAddress *addr_, int port_, int keysize = RSA_KEYSIZE, | | */ | |
| int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | | SSLSocket(InetAddress *addr_, int port_, int keysize = RSA_K | |
| | | EYSIZE, int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
|
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| SSLSocket(InetAddress *addr_, int port_, InetAddress *local_addr_, | | SSLSocket(InetAddress *addr_, int port_, InetAddress *local_ | |
| int local_port_, int keysize = RSA_KEYSIZE, int timeout_ = 0, int rbuf_ = 6 | | addr_, int local_port_, int keysize = RSA_KEYSIZE, int timeout_ = 0, int rb | |
| 5535, int wbuf_ = 4096); | | uf_ = 65535, int wbuf_ = 4096); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| SSLSocket(std::string host_, int port_, int keysize = RSA_KEYSIZE, | | SSLSocket(std::string host_, int port_, int keysize = RSA_KE | |
| int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | | YSIZE, int timeout_ = 0, int rbuf_ = 65535, int wbuf_ = 4096); | |
| | | | |
|
| /** | | /** | |
| * \brief Constructor. | | * \brief Constructor. | |
| * | | * | |
| */ | | */ | |
| SSLSocket(std::string host_, int port_, InetAddress *local_addr_, i | | SSLSocket(std::string host_, int port_, InetAddress *local_a | |
| nt local_port_, int keysize = RSA_KEYSIZE, int timeout_ = 0, int rbuf_ = 40 | | ddr_, int local_port_, int keysize = RSA_KEYSIZE, int timeout_ = 0, int rbu | |
| 96, int wbuf_ = 4096); | | f_ = 4096, int wbuf_ = 4096); | |
| | | | |
|
| /** | | /** | |
| * \brief Destrutor virtual. | | * \brief Destrutor virtual. | |
| * | | * | |
| */ | | */ | |
| virtual ~SSLSocket(); | | virtual ~SSLSocket(); | |
| | | | |
|
| #ifdef _WIN32 | | /** | |
| virtual SOCKET GetHandler(); | | * \brief | |
| #else | | * | |
| virtual int GetHandler(); | | */ | |
| #endif | | virtual jsocket_t GetHandler(); | |
| | | | |
|
| /** | | /** | |
| * \brief Send bytes to a destination. | | * \brief Send bytes to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual int Send(const char *b_, int size_, bool block_ = true); | | virtual int Send(const char *b_, int size_, bool block_ = tr | |
| | | ue); | |
| | | | |
|
| /** | | /** | |
| * \brief Send bytes to a destination waiting a timeout. | | * \brief Send bytes to a destination waiting a timeout. | |
| * | | * | |
| */ | | */ | |
| virtual int Send(const char *b_, int size_, int time_); | | virtual int Send(const char *b_, int size_, int time_); | |
| | | | |
|
| /** | | /** | |
| * \brief Receive bytes from a source. | | * \brief Receive bytes from a source. | |
| * | | * | |
| * \return the number of bytes received, or 0 if the peer has | | * \return the number of bytes received, or 0 if the peer ha | |
| shutdown (now throws). | | s shutdown (now throws). | |
| * | | * | |
| * \exception SocketException an error occurred. | | * \exception SocketException an error occurred. | |
| * | | * | |
| */ | | */ | |
| virtual int Receive(char *data_, int data_length_, bool block_ = tr | | virtual int Receive(char *data_, int data_length_, bool bloc | |
| ue); | | k_ = true); | |
| | | | |
|
| /** | | /** | |
| * \brief Receive bytes from a source waiting a timeout. | | * \brief Receive bytes from a source waiting a timeout. | |
| * | | * | |
| */ | | */ | |
| virtual int Receive(char *data_, int data_length_, int time_); | | virtual int Receive(char *data_, int data_length_, int time_ | |
| | | ); | |
| | | | |
|
| /** | | /** | |
| * \brief Close the socket. | | * \brief Close the socket. | |
| * | | * | |
| */ | | */ | |
| virtual void Close(); | | virtual void Close(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::InputStream * GetInputStream(); | | virtual jio::InputStream * GetInputStream(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual jio::OutputStream * GetOutputStream(); | | virtual jio::OutputStream * GetOutputStream(); | |
| | | | |
|
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| InetAddress * GetInetAddress(); | | InetAddress * GetInetAddress(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the local port. | | * \brief Get the local port. | |
| * | | * | |
| */ | | */ | |
| int GetLocalPort(); | | int GetLocalPort(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the port. | | * \brief Get the port. | |
| * | | * | |
| */ | | */ | |
| int GetPort(); | | int GetPort(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the bytes sent to a destination. | | * \brief Get the bytes sent to a destination. | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetSentBytes(); | | virtual int64_t GetSentBytes(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get de bytes received from a source. | | * \brief Get de bytes received from a source. | |
| * | | * | |
| */ | | */ | |
| virtual int64_t GetReadedBytes(); | | virtual int64_t GetReadedBytes(); | |
| | | | |
|
| /** | | /** | |
| * \brief Get the socket options. | | * \brief Get the socket options. | |
| * | | * | |
| */ | | */ | |
| SocketOption * GetSocketOption(); | | SocketOption * GetSocketOption(); | |
| | | | |
| /** | | /** | |
| * Cert files (if not set, a temporary RSA session cert will
be created if needed) | | * Cert files (if not set, a temporary RSA session cert will
be created if needed) | |
| * | | * | |
| * PEM format | | * PEM format | |
| */ | | */ | |
| bool UseCert(const char *cert_file, const char *private_key_
file); | | bool UseCert(const char *cert_file, const char *private_key_
file); | |
| | | | |
| /** | | /** | |
| * As use_cert() but also give pasord for private_key_file (
or get OpenSSL's standard prompt each time) | | * As use_cert() but also give pasord for private_key_file (
or get OpenSSL's standard prompt each time) | |
| | | | |
End of changes. 27 change blocks. |
| 153 lines changed or deleted | | 151 lines changed or added | |
|
| jthread.h | | jthread.h | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| NORMAL_PRIORITY, | | NORMAL_PRIORITY, | |
| HIGH_PRIORITY | | HIGH_PRIORITY | |
| }; | | }; | |
| | | | |
| enum jthread_policy_t { | | enum jthread_policy_t { | |
| POLICY_OTHER, // Normal thread | | POLICY_OTHER, // Normal thread | |
| POLICY_FIFO, // Real-time thread fifo | | POLICY_FIFO, // Real-time thread fifo | |
| POLICY_ROUND_ROBIN // Round robin thread round robin | | POLICY_ROUND_ROBIN // Round robin thread round robin | |
| }; | | }; | |
| | | | |
|
| struct jthread_map_t { | | | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
|
| HANDLE thread; | | typedef HANDLE jthread_t; | |
| #else | | #else | |
|
| pthread_t thread; | | typedef pthread_t jthread_t; | |
| #endif | | #endif | |
|
| | | | |
| | | struct jthread_map_t { | |
| | | jthread_t thread; | |
| bool alive; | | bool alive; | |
| }; | | }; | |
| | | | |
| class ThreadGroup; | | class ThreadGroup; | |
| | | | |
| /** | | /** | |
| * \brief Thread. | | * \brief Thread. | |
| * | | * | |
| * @author Jeff Ferr | | * @author Jeff Ferr | |
| */ | | */ | |
| class Thread : public virtual jcommon::Object{ | | class Thread : public virtual jcommon::Object{ | |
| | | | |
| private: | | private: | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| /** \brief */ | | /** \brief */ | |
|
| HANDLE _thread; | | | |
| /** \brief */ | | | |
| DWORD _thread_id; | | DWORD _thread_id; | |
| /** \brief */ | | /** \brief */ | |
| DWORD _stackSize; | | DWORD _stackSize; | |
| /** \brief */ | | /** \brief */ | |
| DWORD _executeFlag; | | DWORD _executeFlag; | |
| /** \brief */ | | /** \brief */ | |
| LPTHREAD_START_ROUTINE _threadFunction; | | LPTHREAD_START_ROUTINE _threadFunction; | |
| /** \brief */ | | /** \brief */ | |
| LPVOID _threadArgument; | | LPVOID _threadArgument; | |
| /** \brief */ | | /** \brief */ | |
| LPSECURITY_ATTRIBUTES _sa; | | LPSECURITY_ATTRIBUTES _sa; | |
| /** \brief */ | | /** \brief */ | |
| DWORD _exitCode; | | DWORD _exitCode; | |
| #else | | #else | |
| /** \brief */ | | /** \brief */ | |
|
| pthread_t _thread; | | | |
| /** \brief */ | | | |
| Condition _condition; | | Condition _condition; | |
| #endif | | #endif | |
| /** \brief */ | | /** \brief */ | |
|
| | | jthread_t _thread; | |
| | | /** \brief */ | |
| std::map<int, jthread_map_t *> _threads; | | std::map<int, jthread_map_t *> _threads; | |
| /** \brief */ | | /** \brief */ | |
| Mutex jthread_mutex; | | Mutex jthread_mutex; | |
| /** \brief */ | | /** \brief */ | |
| Runnable *_runnable; | | Runnable *_runnable; | |
| /** \brief */ | | /** \brief */ | |
| ThreadGroup *_group; | | ThreadGroup *_group; | |
| /** \brief */ | | /** \brief */ | |
| jthread_type_t _type; | | jthread_type_t _type; | |
| /** \brief */ | | /** \brief */ | |
|
| int _key; | | int _id; | |
| /** \brief */ | | /** \brief */ | |
| bool _is_running; | | bool _is_running; | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| #ifdef _WIN32 | | #ifdef _WIN32 | |
| static DWORD WINAPI ThreadMain(void *owner_); | | static DWORD WINAPI ThreadMain(void *owner_); | |
| #else | | #else | |
| static void * ThreadMain(void *owner_); | | static void * ThreadMain(void *owner_); | |
| #endif | | #endif | |
| | | | |
| /** | | /** | |
| * \brief Notify the end of thread. | | * \brief Notify the end of thread. | |
| * | | * | |
| */ | | */ | |
|
| jthread_map_t * GetMap(int key); | | jthread_map_t * GetMap(int id); | |
| | | | |
| protected: | | protected: | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| virtual int SetUp(); | | virtual int SetUp(); | |
| | | | |
| /** | | /** | |
| * \brief Dont use try-catch(...) | | * \brief Dont use try-catch(...) | |
| | | | |
| skipping to change at line 195 | | skipping to change at line 195 | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| static void USleep(uint64_t time_); | | static void USleep(uint64_t time_); | |
| | | | |
| /** | | /** | |
| * \brief Get thread identifier | | * \brief Get thread identifier | |
| * | | * | |
| */ | | */ | |
|
| int GetKey(); | | jthread_t GetHandler(); | |
| | | | |
| | | /** | |
| | | * \brief Get thread identifier | |
| | | * | |
| | | */ | |
| | | int GetID(); | |
| | | | |
| /** | | /** | |
| * \brief | | * \brief | |
| * | | * | |
| */ | | */ | |
| void KillAllThreads(); | | void KillAllThreads(); | |
| | | | |
| /** | | /** | |
| * \brief Init the thread. | | * \brief Init the thread. | |
| * | | * | |
| */ | | */ | |
|
| void Start(int key = 0); | | void Start(int id = 0); | |
| | | | |
| /** | | /** | |
| * \brief Interrupt the thread. | | * \brief Interrupt the thread. | |
| * | | * | |
| */ | | */ | |
|
| bool Interrupt(int key = 0); | | bool Interrupt(int id = 0); | |
| | | | |
| /** | | /** | |
| * \brief Suspend the thread. | | * \brief Suspend the thread. | |
| * | | * | |
| */ | | */ | |
|
| void Suspend(int key = 0); | | void Suspend(int id = 0); | |
| | | | |
| /** | | /** | |
| * \brief Resume the thread. | | * \brief Resume the thread. | |
| * | | * | |
| */ | | */ | |
|
| void Resume(int key = 0); | | void Resume(int id = 0); | |
| | | | |
| /** | | /** | |
| * \brief Return true if thread is started, false if not. | | * \brief Return true if thread is started, false if not. | |
| * | | * | |
| */ | | */ | |
|
| bool IsRunning(int key = 0); | | bool IsRunning(int id = 0); | |
| | | | |
| /** | | /** | |
| * \bried | | * \bried | |
| * | | * | |
| */ | | */ | |
| void Yield(); | | void Yield(); | |
| | | | |
| /** | | /** | |
| * \bried | | * \bried | |
| * | | * | |
| | | | |
| skipping to change at line 255 | | skipping to change at line 261 | |
| /** | | /** | |
| * \bried | | * \bried | |
| * | | * | |
| */ | | */ | |
| void GetPolicy(jthread_policy_t *policy, jthread_priority_t
*priority); | | void GetPolicy(jthread_policy_t *policy, jthread_priority_t
*priority); | |
| | | | |
| /** | | /** | |
| * \brief Wait for end of thread. | | * \brief Wait for end of thread. | |
| * | | * | |
| */ | | */ | |
|
| void WaitThread(int key = 0); | | void WaitThread(int id = 0); | |
| | | | |
| /** | | /** | |
| * \brief Wait for end of thread. | | * \brief Wait for end of thread. | |
| * | | * | |
| */ | | */ | |
| void Release(); | | void Release(); | |
| | | | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
End of changes. 16 change blocks. |
| 16 lines changed or deleted | | 22 lines changed or added | |
|