connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h
changeset 60 9d2210c8eed2
child 366 b054461d2f85
equal deleted inserted replaced
59:c892c53c664e 60:9d2210c8eed2
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 // TcpComm.h: interface for the CTcpComm class.
       
    18 //
       
    19 //////////////////////////////////////////////////////////////////////
       
    20 
       
    21 #if !defined(AFX_TCPCOMM_H__69657421_6D37_497A_A377_12E71365EDAB__INCLUDED_)
       
    22 #define AFX_TCPCOMM_H__69657421_6D37_497A_A377_12E71365EDAB__INCLUDED_
       
    23 
       
    24 #if _MSC_VER > 1000
       
    25 #pragma once
       
    26 #endif // _MSC_VER > 1000
       
    27 
       
    28 #include "BaseCom.h"
       
    29 #include <winsock2.h>
       
    30 
       
    31 #define MAX_MESSAGE_LENGTH	(64*1024L)
       
    32 #define MAX_TCP_MESSAGE_BUFFER_LENGTH (8*MAX_MESSAGE_LENGTH)
       
    33 
       
    34 #define DEFAULT_SOCKET_TIMEOUT	(2000000L)	// 2 seconds
       
    35 #define TIMEOUT_SEC(x) (x/1000000L)
       
    36 #define TIMEOUT_USEC(x) (x%1000000L)
       
    37 
       
    38 class CTcpComm : public CBaseCom  
       
    39 {
       
    40 public:
       
    41 	CTcpComm();
       
    42 	CTcpComm(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol);
       
    43 	virtual ~CTcpComm();
       
    44 
       
    45 	virtual long OpenPort();
       
    46 	long ClosePort();
       
    47 	long SendDataToPort(DWORD inSize, const void* inData);
       
    48 	long PollPort(DWORD& outSize);
       
    49 	long ReadPort(DWORD inSize, void* outData, DWORD& outSize);
       
    50 	long ProcessBuffer(CConnection* pConn, CRegistry* pRegistry, long& numberProcessed);
       
    51 //	long ProcessBuffer(NOTIFYCLIENTSCOMMERROR pNotify, ROUTEMESSAGE pRouteMessage, long& numberProcessed);
       
    52 //	long ProcessBuffer(long& numberProcessed);
       
    53 	void DeleteMsg(DWORD inMsgLength);
       
    54 	bool GetVersion(char* outVersion) { return false; } // don't have enough information for this
       
    55 	bool HasVersion() { return false; } // can we have a version?
       
    56 	virtual long PreProcessMessage(int inMsgType, DWORD inMsgLength, BYTE* inMessage) { return TCAPI_ERR_NONE; }
       
    57 	virtual long PreProcessMessage(BYTE msgId, DWORD inMsgLength, BYTE* inMessage) { return TCAPI_ERR_NONE; }
       
    58 	bool IsConnectionEqual(ConnectData* pConn);
       
    59 
       
    60 private:
       
    61 	SOCKET m_socket;
       
    62 	sockaddr_in m_clientService;
       
    63 	TIMEVAL m_timeOut;
       
    64 	WSAEVENT m_hSocketEvent; 
       
    65 	DWORD m_pPeekBuffer;
       
    66 
       
    67 };
       
    68 
       
    69 #endif // !defined(AFX_TCPCOMM_H__69657421_6D37_497A_A377_12E71365EDAB__INCLUDED_)