2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file SocketStream.h
18 * @author Zofia Abramowska (z.abramowska@samsung.com)
20 * @brief Header of socket stream class.
23 #ifndef SOCKETSTREAM_H_
24 #define SOCKETSTREAM_H_
27 #include <sys/socket.h>
28 #include <sys/select.h>
29 #include <dpl/serialization.h>
30 #include <dpl/log/log.h>
33 * This class implements binary read/write from socket used for DPL serialization and deserialization
34 * It can read or write buffers of max *total* size 10kB.
35 * I does not maintain socket descriptor.
39 * Throws SocketStreamException when buffer is null or its size exceeds max size or when
40 * there is an error during read or write.
45 class SocketStream : public DPL::IStream {
50 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
51 DECLARE_EXCEPTION_TYPE(Base, SocketStreamException)
54 explicit SocketStream(int socket_fd) : m_socketFd(socket_fd),
60 void Read(size_t num, void * bytes);
61 void Write(size_t num, const void * bytes);
63 void throwWithErrnoMessage(std::string specificInfo);
69 #endif /* SOCKETSTREAM_H_ */