void DSocket::SendControlMessage(int type,char *address)
{
char data[1000];
int n;
// Prepare the data packet 
// Type of control packet
data[0]=type;
// Length of hostname
n=strlen(localname);
data[1]=n;
// Name of the sender host
memcpy(&data[2],localname,n);
if(address==NULL)
{//AfxMessageBox("sendto address success");
// SendTo(data,n+2,PORT_CONTROL,remoteaddress,strlen(remoteaddress));
    Connect(remoteaddress,PORT_CONTROL);
Send(data,n+2,0);
this->Receivedata();
return;
}
else
{ Connect(address,PORT_CONTROL);
AfxMessageBox(data);
//SendTo(data,n+2,PORT_CONTROL,address); Send(data,n+2,0);
DSocket::Receivedata();
return;
}
}
/**
*    Invoked when any data arrives from the remote host
*
*/
void DSocket::Receivedata()
{
CString address;
char hname[400],str[1000],mesg[500];
unsigned int port,retvalue;
int n,len;
AfxMessageBox("OnReceive success");
//RequestDlg rdlg(NULL);
// Note : if no error has occured then RETVALUE contains
//   the COUNT of actual bytes received.
// Control type 
if(type==TYPE_CONTROL)
{//port=PORT_CONTROL;
        retvalue=this->Receive(data,length);
AfxMessageBox("ReceiveFrom success");
if(retvalue==SOCKET_ERROR)
return;
//Get host name from the data.
for(int i=0;i<data[1];i++)
hname[i]=data[i+2];
hname[i]=0;
strcpy(remotename,hname);
//strcpy(remoteaddress,(LPCTSTR)address);
switch(data[0])
{ // action   : Remote user has sent the invitation for conference
// reaction : accept/reject the invitation
case MESG_CONNECT:
AfxMessageBox("MESG_CONNECT success");
((CMyDlg*)pdlg)->StartConference();
// display the accept , reject dialog box
//rdlg.SetParameter(remotename,remoteaddress,pdlg);
//rdlg.DoModal();
return;
        // action   : Remote user has disconnected
// reaction : destroy the conference
case MESG_DISCONNECT:
            //( (CVideoNetDlg*)pdlg)->DestroyConference();
    sprintf(str,"User %s has disconnected",hname);
AfxMessageBox(str);
return;
// action   : Remote user has accepted the invitation
// reaction : start the conference
// case MESG_ACCEPT:
// AfxMessageBox("User has accepted the connection");
      //  ((CMyDlg*)pdlg)->StartConference();
// return;
            // action   : Remote user has rejected the invitation
// reaction : what to do...?
case MESG_REJECT:
sprintf(str,"User %s has rejected your invitation",hname);
AfxMessageBox(str);
return;

}

return;

}
if(type==TYPE_AUDIO)
{

retvalue=this->ReceiveFrom(adata,alength,address,port); if(retvalue==SOCKET_ERROR)
return;
// Play the audio
// ((CVideoNetDlg *)pdlg)->play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,retvalue,(LPARAM)adata);
return;
}
if(type==TYPE_VIDEO)
{ retvalue=this->ReceiveFrom(vdata,vlength,address,port);
if(retvalue==SOCKET_ERROR)
return;
// ((CVideoNetDlg *)pdlg)->DisplayRemoteFrame(vdata,retvalue); return;
}
if(type==TYPE_TEXT)
{
// CString strtr="192.168.0.5";
retvalue=this->Receive(data,length);
//retvalue=this->ReceiveFrom(data,length,strtr,port);
if(retvalue==SOCKET_ERROR)
return;
// Get host name from the data.
// Length of username
n=data[1];
for(int i=0;i<n;i++)
hname[i]=data[i+2];
hname[i]=0;
len=data[n+2] | ( data[n+3]<<8 );
memcpy(mesg,&data[n+4],len);
mesg[len]=0;
        //AfxMessageBox("TYPE_TEXT,success");
sprintf(str,"%s >> %s ",hname,mesg);
//this->ShutDown(0);
// Display message in list bo
//CString str=data;
// AfxMessageBox(str);
((CMyDlg *)pdlg)->DisplayMesg(str);
return;
// }}
为什么编译时出现D:\Microsoft Visual Studio\MyProjects\DSocket.cpp(254) : error C2601: 'SendControlMessage' : local function definitions are illegal