3d7b9fe0cac133e0edcb724cbbb6ace9da3c0888
[platform/framework/web/wrt-commons.git] / modules / socket / include / dpl / socket / unix_socket.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file        unix_socket.h
18  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version     1.0
20  * @brief       This file is the header file of unix socket
21  */
22 #ifndef DPL_UNIX_SOCKET_H
23 #define DPL_UNIX_SOCKET_H
24
25 #include <dpl/socket/generic_socket.h>
26 #include <dpl/exception.h>
27
28 namespace DPL
29 {
30 namespace Socket
31 {
32
33 class UnixSocket
34     : public GenericSocket<UnixSocket>
35 {
36 public:
37     class Exception
38     {
39     public:
40         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
41         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
42     };
43
44 protected:
45      /**
46       * Translate generic Address to specific socket kernel structure
47       */
48     virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(const Address &address) const;
49
50     /**
51      * Translate specific socket kernel structure to generic Address
52      */
53     virtual Address TranslateAddressSpecificToGeneric(sockaddr *, socklen_t) const;
54
55     /**
56      * Get specific socket kernel structure size
57      */
58     virtual socklen_t GetSpecificAddressSize() const;
59
60     /**
61      * Alloc specific implementation of socket from descriptor
62      */
63     virtual UnixSocket *AllocAcceptedSpecificSocket() const;
64
65     /**
66      * Alloc specific implementation of socket descriptor
67      */
68     virtual int AllocSpecificDescriptor() const;
69
70 public:
71     UnixSocket();
72
73     virtual void Bind(const Address &address);
74 };
75
76 }
77 } // namespace DPL
78
79 #endif // DPL_GENERIC_SOCKET_H