1 #ifndef DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
2 #define DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/internal/network/common/socket-interface.h>
33 * @brief Concrete implementation of a socket under Linux.
35 * Provides automatic closing of socket on destruction.
37 class Socket : public SocketInterface
43 * @param protocol network protocol
44 * @param fileDescriptor option file descriptor if the socket is already open
46 Socket( Protocol protocol , int fileDescriptor = -1 );
49 * @copydoc Dali::Internal::Adaptor::SocketIsOpen()
51 bool SocketIsOpen() const override;
54 * @copydoc Dali::Internal::Adaptor::SocketInterface::CloseSocket
56 bool CloseSocket() override;
59 * @copydoc Dali::Internal::Adaptor::SocketInterface::Bind
61 bool Bind( uint16_t port ) override;
64 * @copydoc Dali::Internal::Adaptor::SocketInterface::Listen
66 bool Listen( int blacklog) override;
69 * @copydoc Dali::Internal::Adaptor::SocketInterface::Accept
71 SocketInterface* Accept() const override;
74 * @copydoc Dali::Internal::Adaptor::SocketInterface::Select
76 SelectReturn Select( ) override;
79 * @copydoc Dali::Internal::Adaptor::SocketInterface::ExitSelect
81 void ExitSelect() override;
84 * @copydoc Dali::Internal::Adaptor::SocketInterface::Recieve
86 bool Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead ) override;
89 * @copydoc Dali::Internal::Adaptor::SocketInterface::Send
91 bool Write( const void* buffer, unsigned int bufferLength ) override;
94 * @copydoc Dali::Internal::Adaptor::SocketInterface::ReuseAddress
96 bool ReuseAddress( bool reUse ) override;
99 * @copydoc Dali::Internal::Adaptor::SocketInterface::SetBufferSize
102 bool SetBufferSize( SocketInterface::BufferType type, unsigned int bufferSizeInBytes ) override;
105 * @brief Virtual destructor
113 * @brief Helper to create the quit pipe
115 bool CreateQuitPipe();
118 * @brief Helper to delete the quit pipe
120 void DeleteQuitPipe();
122 int mSocketFileDescriptor; ///< file descriptor
123 int mQuitPipe[2]; ///< Pipe to inform Select to quit.
124 bool mBound:1; ///< whether the socket is bound
125 bool mListening:1; ///< whether the socket is being listen to
126 bool mQuitPipeCreated:1; ///< whether the quit pipe has been created
127 bool mBlocked:1; ///< whether the socket is blocked waiting for a connection
138 #endif // DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H