Initialize Tizen 2.3
[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 namespace Socket {
30 class UnixSocket :
31     public GenericSocket<UnixSocket>
32 {
33   public:
34     class Exception
35     {
36       public:
37         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
38         DECLARE_EXCEPTION_TYPE(Base, CreateFailed)
39     };
40
41   protected:
42     /**
43      * Translate generic Address to specific socket kernel structure
44      */
45     virtual std::pair<sockaddr *, socklen_t> TranslateAddressGenericToSpecific(
46         const Address &address) const;
47
48     /**
49      * Translate specific socket kernel structure to generic Address
50      */
51     virtual Address TranslateAddressSpecificToGeneric(sockaddr *,
52                                                       socklen_t) const;
53
54     /**
55      * Get specific socket kernel structure size
56      */
57     virtual socklen_t GetSpecificAddressSize() const;
58
59     /**
60      * Alloc specific implementation of socket from descriptor
61      */
62     virtual UnixSocket *AllocAcceptedSpecificSocket() const;
63
64     /**
65      * Alloc specific implementation of socket descriptor
66      */
67     virtual int AllocSpecificDescriptor() const;
68
69   public:
70     UnixSocket();
71
72     virtual void Bind(const Address &address);
73 };
74 }
75 } // namespace DPL
76
77 #endif // DPL_GENERIC_SOCKET_H