rip.dwSize=sizeof(RASPPPIP);
if ( (ret=RasGetProjectionInfo(hCon,RASP_PppIp,
(LPVOID) &rip,(LPDWORD) &ll ) ) != 0 )
{ShowMsg(hWin,“ 取IP 地 址 失 败");break;}
ShowMsg(hWin,rip.szIpAddress);ShowMsg(hWin,
“ Send IP Adrress. !");
FtpWriteRead( “ftp.maoming.gd.cn",“abc.txt",
strlen(rip.szIpAddress),rip.szIpAddress,0);
}
else
{ShowMsg(hWin,“Connect internet fail");}
}//if ( strstr(szMsg,“REQUEST") != NULL )
if ( strstr(szMsg,“DISCONNECT") != NULL )
{
send(rsock,“OK",2,0);
closesocket(rsock);RasHangUp(hCon);
} //end if ( strstr(szMsg,“DISCONNECT") != NULL )
} //end if (status)
else
{ShowMsg(hWin,“ 连 接 断 开! 等 待 下 一 个");
closesocket(rsock);}
} //end while( TRUE )
if(hCon != NULL )
{RasHangUp(hCon);Sleep(3000);}
hCon =NULL;closesocket(serv_sock);hThread=NULL;
return;
}
// 实 现 本 地 计 算 机 向 远 程 计 算 机
发 送 命 令 的 函 数 cIp 远 程 计 算 机
IP 地 址 SzCmd 命 令 字 符 串
BOOL SendCmd(char * cIp,char * szCmd)
{
SOCKADDR_IN dest_sin; // 地 址
int status;
char szMsg[ MY_MSG_LENGTH ];
rsock = socket(AF_INET,SOCK_STREAM,0);
dest_sin.sin_family=AF_INET;dest_sin.sin_
addr.s_addr = inet_addr(cIp);
dest_sin.sin_port=htons(1023);
if (connect( rsock,(PSOCKADDR)
&dest_sin,sizeof(dest_sin) )<0 )
{ShowMsg(hWin,“ 连 接 失 败");
closesocket( rsock );return FALSE;}
if ( send(rsock,szCmd,strlen(szCmd),0) != strlen(szCmd))
{ShowMsg(hWin,“ 送 命 令 失 败");
closesocket( rsock );return FALSE;}
status = recv( rsock, szMsg, MY_MSG
_LENGTH, NO_FLAGS_SET );
if (status == SOCKET_ERROR)
{ShowMsg(hWin,“Recv Error!");
closesocket( rsock );return FALSE;}
szMsg[status] = ‘\0'';
if ( status != 0 & & strstr(szMsg,“OK") != NULL )
{closesocket( rsock );return TRUE;}
closesocket( rsock );return FALSE;
}