⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cworkersocket.h

📁 WINCE下的流媒体播放器服务端
💻 H
字号:
//
/*=========================================================================
Base Class
CWorkerSocket.h
==========================================================================*/ 

#if !defined(__CWorkerSocket_h__)
#define __CWorkerSocket_h__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// Error codes 
#define S_SOCKET_OK                      0X10
#define E_SOCKET_CLOSE		             0X11
#define E_SOCKET_FAIL                    0X12
#define E_SOCKET_NOT_READY               0x13

// Define of Message header
typedef struct
{
	unsigned int    nMsgType:8;      // Payload type
	unsigned int    nDataSize:16;    // Payload size
} MSG_HEADER, *PMSG_HEADER;

// Message From Server to Client
#define RECV_EXIT                        0x20  // Indicate stop receiving thread

// Message From Client to Server
#define RECV_EXIT_REQUEST                0x21  // Request the remote to send some data

//////////////////////////////////////////////////////////////////////////////
class CWorkerSocket
{
public:
	CWorkerSocket();
	virtual ~CWorkerSocket();

// Attributes
protected:
	SOCKET    m_hSocket;
	bool      m_bReceiving;
	bool      m_bSending;

	HANDLE    m_hThrdFinish;
	HANDLE    m_hSendFinish;

public:
	bool Attach( SOCKET inSock );
	SOCKET Detach( void );
	int  Send( char * inData, int inLen );
	int  Receive( char * outBuf, int inLen );
	bool Connect( char * inIpAddress, int inPort );
	void Disconnect( void );

	// Receive functions
	bool StartReceiving( void );
	bool StopReceiving( void );
	virtual void ReceivingLoop( void );
	static UINT ReceivingThrd( void * pParam );

	// Send functions
	bool StartSending( void );
	bool StopSending( void );
	virtual void SendingLoop( void );
	static UINT SendingThrd( void * pParam );
};

#endif // !defined(__CWorkerSocket_h__)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -