Many changes in new agent code
[public/netxms.git] / src / agent / core / session.cpp
CommitLineData
e9580fef
VK
1/*
2** NetXMS multiplatform core agent
3** Copyright (C) 2003, 2004 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation; either version 2 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
19** $module: session.cpp
20**
21**/
22
23#include "nxagentd.h"
24
25
26//
27// Client session class constructor
28//
29
30CommSession::CommSession(SOCKET hSocket, DWORD dwHostAddr)
31{
32 m_pSendQueue = new Queue;
33 m_pMessageQueue = new Queue;
34 m_hSocket = hSocket;
35 m_dwIndex = INVALID_INDEX;
36 m_pMsgBuffer = (CSCP_BUFFER *)malloc(sizeof(CSCP_BUFFER));
37 m_hCondWriteThreadStopped = ConditionCreate(FALSE);
38 m_hCondProcessingThreadStopped = ConditionCreate(FALSE);
39 m_dwHostAddr = dwHostAddr;
40}
41
42
43//
44// Destructor
45//
46
47CommSession::~CommSession()
48{
49 shutdown(m_hSocket, 2);
50 closesocket(m_hSocket);
51 delete m_pSendQueue;
52 delete m_pMessageQueue;
53 safe_free(m_pMsgBuffer);
54 ConditionDestroy(m_hCondWriteThreadStopped);
55 ConditionDestroy(m_hCondProcessingThreadStopped);
56}