2015-01-17 8 views
0

클라이언트에서 마우스 위치 보내는 법 A = to => SERVER = to => client B?
아래 예제 코드는 각 위치 출력을 제공합니다 2 초
더 빠르고 더 좋은 방법은 무엇입니까?
주의 사항 : 윈속을 사용하고 컬 안티 바이러스 악성 코드 경고를
사용법을 제공합니다 : 원격 제어

클라이언트로 서버에 클라이언트 A에서 마우스 위치를 전송 현재 TEST 예 :인터넷을 통해 마우스 위치 전송

1.write 마우스 위치를 하지
5.download 온도 경우
2.store X, TEMP.TXT 파일
4.remove receve.txt 같은 서버 파일 send.txt
3.upload sent.txt에서의 Y는 80 // 에러가 존재한다면 .티 receve.txt
6.read의 receve.txt 및 디스플레이 등의 XT는 그런 것들에 대한 좋아요,

int x,y; //positions 
LPCWSTR s=L"C://Documents and Settings//Administrator//Desktop//c++//FTP//send.txt";//location of file for sending 
LPCWSTR r=L"C://Documents and Settings//Administrator//Desktop//c++//FTP//receve.txt";//location of received file 
POINT cursor_pos;//for cursor position 

HINTERNET hInternet; 
    HINTERNET hFtpSession; 
    hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); 
    if (hInternet == NULL) 
    { 
     cout << "Error: " << GetLastError(); 
    } 
    else 
    { 

     hFtpSession = InternetConnect(hInternet, L"www.test.net", INTERNET_DEFAULT_FTP_PORT, L"user", L"pass", INTERNET_SERVICE_FTP, 0, 0); 
     if (hFtpSession == NULL)//not connect 
     { 
      cout << "Error: " << GetLastError(); 
     } 
     else 
     {  


      for(;;){ 
//file input 
fstream inp; 
inp.open(s); 

GetCursorPos(&cursor_pos); 
inp<<cursor_pos.x<<" "<<cursor_pos.y<<endl;//write curent position 



inp.close(); 

      //UPLOADING 
      if (!FtpPutFile(hFtpSession, s, L"//public_html//test//temp.txt", FTP_TRANSFER_TYPE_BINARY, 0)) 
      { 
       cout << "ErrorPutFile: " << GetLastError(); 
       return 0; 
      } 


      remove("C://Documents and Settings//Administrator//Desktop//c++//FTP//receve.txt");//error 80 if file exist so remove it 
      //DOWNLOADING 
      if(!FtpGetFile(hFtpSession,L"//public_html//test//temp.txt",r,TRUE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0)) 
      { 

      cout <<"ErrorGetFile"<<GetLastError(); 
      return 0; 
      }//DELETING 
      if(!FtpDeleteFile(hFtpSession,L"//public_html//test//temp.txt")){ 

      cout <<"ErrorGetFile"<<GetLastError(); 
      return 0; 

      } 



ifstream outp(r); 

while(outp>>x>>y){ 
cout<<"X: "<<x<<" "<<"Y:"<<y<<endl;//read coordinates 

} 
outp.close(); 

      } 



     } 
    } 

return 0; 

당신은 SignalR을 고려해 볼 수 있습니다 시간 :

+0

코드가 작동하고 코드를 향상시키고 싶다면 해당 사이트는 http://codereview.stackexchange.com/ – bolov

+1

입니다. 간단한 개선 사항은 파일에 아무것도 저장하지 않고 보내는 것일뿐입니다 변수 자체로부터 데이터의 원시 바이트 (cursor_pos.x를 short에 할당하므로 커서가 실제로 정의 된 길이가 필요하지 않으므로 cursor_pos.y는 구조체가 정의한대로 보낸다). –

+0

FTP 서버를 중개자로 사용하는 것 같습니다. 속도를 높이기 위해 자신의 서버를 작성하여 연결된 모든 클라이언트에 데이터를 전달하거나 (서버를 변경할 수없는 경우) FTP 서버를 사용하여 다른 클라이언트를 찾아 직접 연결할 수 있습니다. – Galik

답변