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

📄 dsocket.cpp

📁 这是在PDA上运行的视频接受
💻 CPP
字号:
////////////////////////////////////////////////////////////////////////////
//
//
//    Project     : VideoNet version 1.1.
//    Description : Peer to Peer Video Conferencing over the LAN.
//	  Author      :	Nagareshwar Y Talekar ( nsry2002@yahoo.co.in)
//    Date        : 15-6-2004.
//
//
//    File description : 
//    Name    : DSocket.cpp
//    Details : Datagram Socket for communication
//
//
//			***  Control Packet Format ***
//		 Type				: 1 byte
//		 Length of hostname : 1 byte
//		 Hostname			: <var>
//
//			***  Text packet format ***
//       Type               : 1 byte
//		 Length of hostname	: 1 byte
//		 Hostname           : < var>
//       Length of message  : 2 byte
//		 Message            : <var>
//
//			***  Audio packet format ***
//       Type				  : 1 byte
//		 Length of hostname	  : 1 byte
//		 Hostname             : < var>
//       size of audio data   : 2 byte
//		 Audio data           : <var>
//	
//			***  Video packet format ***
//       Type                 : 1 byte
//		 Length of hostname	  : 1 byte
//		 Hostname             : < var>
//       size of video data   : 2 byte
//		 Video data           : <var>
//
//
//
/////////////////////////////////////////////////////////////////////////////


#include "stdafx.h"
#include "VideoNet2.h"
#include "DSocket.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// DSocket

// Initialize static members...
CString DSocket::remoteaddress=_T("");



DSocket::DSocket()
{
	
	
}

DSocket::~DSocket()
{
}


// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(DSocket, CSocket)
//{{AFX_MSG_MAP(DSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// DSocket member functions



/**
*    Creates datagram socket on specified port 
*    @param port Port on which datagram socket is created
*    @param type type indicates the purpose of this socket
*			which can be control, audio or video.
*/

void DSocket::CreateSocket(int port,int dtype)
{
	
	
	this->Create(port,SOCK_DGRAM);
	type=dtype;
		
}


/**
*    Invoked when any data arrives from the remote host
*
*/
void DSocket::OnReceive(int errcode)
{
	
}


/**
*       Send the control data to remote host
*
*
*/
void DSocket::SendControlMessage(int type,LPCTSTR address)
{
	char data[1000];
	int n = 1;
	
	// Prepare the data packet 
	
	// Type of control packet
	data[0]=type;				

	SendTo(data,n+2,PORT_CONTROL,remoteaddress);
	
}

/**
*    Closes the socket created by the createsocket method
*
*/
void DSocket::CloseSocket()
{
	
	DSocket::Close();
	
}

⌨️ 快捷键说明

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