NCBI C++ ToolKit
ncbi_socket_unix.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CONNECT___NCBI_SOCKET_UNIX__HPP
2 #define CONNECT___NCBI_SOCKET_UNIX__HPP
3 
4 /* $Id: ncbi_socket_unix.hpp 61401 2014-01-17 20:31:07Z lavr $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Anton Lavrentiev
30  *
31  * File Description:
32  * TCP/IP socket API extension for UNIX
33  *
34  */
35 
36 #include <connect/ncbi_socket.hpp>
37 
38 
39 /** @addtogroup Sockets
40  *
41  * @{
42  */
43 
44 
46 
47 
49 {
50 public:
51  // Create unconnected socket
52  CUNIXSocket(void) { }
53 
54  CUNIXSocket(const string& filename,
55  const STimeout* timeout = kInfiniteTimeout,
57 
58  // May be called on a socket, which is not connected yet
59  EIO_Status Connect(const string& filename,
60  const STimeout* timeout = kDefaultTimeout,
62 };
63 
64 
66 {
67 public:
68  // Create unbound socket
70 
71  CUNIXListeningSocket(const string& filename,
72  unsigned short backlog = 64,
74 
75  EIO_Status Listen(const string& filename,
76  unsigned short backlog = 64,
78 };
79 
80 
81 /* @} */
82 
83 
84 /////////////////////////////////////////////////////////////////////////////
85 
86 
87 /////////////////////////////////////////////////////////////////////////////
88 /// IMPLEMENTATION of INLINE functions
89 /////////////////////////////////////////////////////////////////////////////
90 
91 
92 /////////////////////////////////////////////////////////////////////////////
93 /// CUNIXListeningSocket::
94 ///
95 
97  unsigned short backlog,
99 {
100  LSOCK_CreateUNIX(path.c_str(), backlog, &m_Socket, flags);
101 }
102 
103 
104 inline EIO_Status CUNIXListeningSocket::Listen(const string& path,
105  unsigned short backlog,
107 {
108  return m_Socket
109  ? eIO_Unknown
110  : LSOCK_CreateUNIX(path.c_str(), backlog, &m_Socket, flags);
111 }
112 
113 
114 /////////////////////////////////////////////////////////////////////////////
115 
116 
118 
119 #endif /* CONNECT___NCBI_SOCKET_UNIX__H */
CListeningSocket::
CSocket::
static uch flags
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
EIO_Status Connect(const string &host, unsigned short port, const STimeout *timeout=kDefaultTimeout, TSOCK_Flags flags=fSOCK_LogDefault)
Connect to "host:port".
EIO_Status LSOCK_CreateUNIX(const char *path, unsigned short backlog, LSOCK *lsock, TSOCK_Flags flags)
Definition: ncbi_socket.c:6526
EIO_Status Listen(const string &filename, unsigned short backlog=64, TSOCK_Flags flags=fSOCK_LogDefault)
unsigned int TSOCK_Flags
bitwise "OR" of ESOCK_Flags
Definition: ncbi_socket.h:503
@ fSOCK_LogDefault
Definition: ncbi_socket.h:491
#define kInfiniteTimeout
Definition: ncbi_types.h:82
EIO_Status
I/O status.
Definition: ncbi_core.h:132
#define kDefaultTimeout
Definition: ncbi_types.h:81
@ eIO_Unknown
unknown I/O error (likely fatal but can retry)
Definition: ncbi_core.h:139
#define NCBI_XCONNECT_EXPORT
Timeout structure.
Definition: ncbi_types.h:76
Modified on Wed May 22 11:31:36 2024 by modify_doxy.py rev. 669887