File: socket_sys_common.cpp

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (77 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
   FALCON - The Falcon Programming Language.
   FILE: socket_sys_common.cpp

   The socket module (system independant methods).
   -------------------------------------------------------------------
   Author: Stanislas Marquis
   Begin: 2011-11-05 15:59:13

   -------------------------------------------------------------------
   (C) Copyright 2011: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/

/** \file socket_sys_common.cpp
 *  The socket module (system independant methods).
 */

#include <falcon/module.h>
#include "socket_ext.h"
#include "socket_sys.h"
#include "socket_st.h"

namespace Falcon {
namespace Sys {

// ====================================================
// private class socket.

Socket::Socket( const Socket& other ):
   m_address( other.m_address ),
   d(other.d),
   m_ipv6( other.m_ipv6 ),
   m_lastError(other.m_lastError),
   m_timeout(other.m_timeout),
   m_boundFamily(other.m_boundFamily),
   m_refcount(other.m_refcount)
{
   atomicInc( *other.m_refcount );
}

FalconData *Socket::clone() const
{
   return new Socket(*this);
}

Socket::~Socket()
{
   if( atomicDec( *m_refcount ) == 0 )
   {
      // ungraceful close.
      terminate();
      memFree( (void*)m_refcount );
   }
}

// =================================================
// TCP socket.

TCPSocket::TCPSocket( const TCPSocket& other ):
   Socket( other ),
   m_connected(other.m_connected)
{
}


FalconData* TCPSocket::clone() const
{
   return new TCPSocket(*this);
}

} // namespace Sys
} // namespace Falcon

/* end of socket_sys_common.cpp */
/* vim: set ai et sw=3 ts= sts=3: */