toolsandutils/wintunnel/testcode/server/CTcpServer.h
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 /**
       
     2 * Copyright (c) 2003-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 "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 * CTcpServer
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __CTCPSERVER_H__
       
    23 #define __CTCPSERVER_H__
       
    24 
       
    25 
       
    26 /***************************************************************************************
       
    27  *
       
    28  * System Includes
       
    29  *
       
    30  **************************************************************************************/
       
    31 #include <winsock2.h>
       
    32 
       
    33 
       
    34 /***************************************************************************************
       
    35  *
       
    36  * Definitions
       
    37  *
       
    38  **************************************************************************************/
       
    39 #define ITS_OK					0
       
    40 #define E_SOCKETSTARTUP			1								
       
    41 #define E_SOCKETBIND			2						
       
    42 #define E_SOCKETSEND			3			
       
    43 #define E_SOCKETRECV			4							
       
    44 #define E_SOCKETCLOSE			5			
       
    45 #define E_SOCKETSHUTDOWN		6
       
    46 #define E_SENDING				7
       
    47 #define E_RECEIVING				8
       
    48 #define E_LISTENING				9
       
    49 #define	E_ACCEPT				10
       
    50 #define E_INCORRECTARG			11
       
    51 
       
    52 #define RECVBUFFSIZE	1024
       
    53 		
       
    54 
       
    55 /***************************************************************************************
       
    56  *
       
    57  * CTcpServer
       
    58  *
       
    59  **************************************************************************************/
       
    60 class CTcpServer
       
    61 {
       
    62 public:
       
    63 	CTcpServer();	
       
    64 	~CTcpServer();	
       
    65 	int StartServer( char* aLocalInterface, char* aLocalPort );	
       
    66 
       
    67 private:
       
    68 	void ProcessBuffer( char* aBuffer, int aLen );
       
    69 	bool IsBufferComplete( char* aBuffer, int aLen );
       
    70 
       
    71 	int initialise(void);
       
    72 	int disconnect(void);
       
    73 	int release(void);
       
    74 	int setArguments(char* li, char* lp);
       
    75 	int connect( SOCKET &aSocket, SOCKADDR_IN &aAddr );
       
    76 	int makeConnection(SOCKET &aLocalSocket, SOCKET &aRemoteSocket, SOCKADDR_IN &aRemoteAddr);
       
    77 	SOCKET getSocket( void );
       
    78 	SOCKADDR_IN getSockAddr( const char* aIp, const char* aPort );
       
    79 	bool isIPAdress( const char* aAddr );
       
    80 
       
    81 private:
       
    82 	SOCKET iLocal_Sock;
       
    83 	SOCKADDR_IN iLocal_Addr;
       
    84 	SOCKET iRemote_Sock;
       
    85 	SOCKADDR_IN iRemote_Addr;
       
    86 	char iPacket[RECVBUFFSIZE];
       
    87 };
       
    88 
       
    89 #endif //__CTCPSERVER_H__