xwords/xwords4/symbian/inc/symssock.h

93 lines
2.7 KiB
C
Raw Normal View History

2005-02-26 03:57:19 +01:00
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 2005 by Eric House (xwords@eehouse.org). (based on sample
2005-02-26 03:57:19 +01:00
* app helloworldbasic "Copyright (c) 2002, Nokia. All rights
* reserved.")
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SYMSSOCK_H_
#define _SYMSSOCK_H_
#ifndef XWFEATURE_STANDALONE_ONLY
#include <es_sock.h>
#include <in_sock.h>
2005-02-26 03:57:19 +01:00
#include "comms.h"
const TInt KMaxMsgLen = 512;
2005-02-26 03:57:19 +01:00
class CSendSocket : public CActive {
public:
2005-03-09 15:51:11 +01:00
typedef void (*ReadNotifyCallback)( const TDesC8* aBuf,
void *aClosure );
static CSendSocket* NewL( ReadNotifyCallback aCallback, void* aClosure );
2005-02-26 03:57:19 +01:00
~CSendSocket();
TBool SendL( const XP_U8* aBuf, XP_U16 aLen, const CommsAddrRec* aAddr );
2005-03-09 15:51:11 +01:00
TBool Listen();
2005-03-09 15:51:11 +01:00
void ConnectL( const CommsAddrRec* aAddr );
void Disconnect();
2005-02-26 03:57:19 +01:00
protected:
void RunL(); /* from CActive */
void DoCancel(); /* from CActive */
2005-02-26 03:57:19 +01:00
private:
2005-03-09 15:51:11 +01:00
CSendSocket( ReadNotifyCallback aCallback, void* aClosure );
2005-02-26 03:57:19 +01:00
void ConstructL();
void DoActualSend();
2005-03-09 15:51:11 +01:00
void ConnectL();
void ConnectL( TUint32 aIpAddr );
TBool CancelListen();
2005-03-20 20:45:43 +01:00
void ResetState();
2005-03-09 15:51:11 +01:00
enum TSSockState { ENotConnected
,ELookingUp
,EConnecting
,EConnected
,ESending
2005-03-09 15:51:11 +01:00
,EListening
};
2005-02-26 03:57:19 +01:00
TSSockState iSSockState;
RSocket iSendSocket;
RSocketServ iSocketServer;
RHostResolver iResolver;
TInetAddr iAddress;
TBuf8<KMaxMsgLen> iSendBuf;
2005-03-09 15:51:11 +01:00
TInt iDataLen; /* How big should next packet be */
TUint8 iInBuf[KMaxMsgLen];
TPtr8* iInBufDesc; /* points to above buffer */
CommsAddrRec iCurAddr;
TNameEntry iNameEntry;
TNameRecord iNameRecord;
TBool iAddrSet;
2005-03-09 15:51:11 +01:00
TBool iListenPending;
ReadNotifyCallback iCallback;
void* iClosure;
2005-02-26 03:57:19 +01:00
};
#endif
#endif