Results 1 to 2 of 2

Thread: parsing

Threaded View

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    parsing

    the attached text file has the protocol for the server.

    im trying to get it to work in my code, but all of the messageboxes show up as blank when i run it, here to code:

    Code:
    CString CGameOrganizerDlg::Read() {
    	CString tot;
    	bool done=false;
    	char *tmp=NULL;
    
    	while(!done){	
    		sock.Receive(tmp,1);
    		//MessageBox(tmp,"test");
    		if(tmp=='\x00'){
    			done=true;
    		} else{
    			tot+=tmp;
    		}
    	}	
    
    	//MessageBox((LPCSTR)tot,"total");
    	return tot;
    }
    bool CGameOrganizerDlg::Query(GameInfo &ginfo, char *server_name, char type){
    	char *buffer=new char[6];
    	char *send=new char[];
    
    	unsigned short port = this->GetPort(server_name);	//get port
    	CString servern = server_name;						//server name(either ip or hostname)
    	CString serverinfo[6];								//server properties
    
    	int loc;
    	if((loc=servern.Find(';',0)) != -1){
    		servern=servern.Left(servern.GetLength() - loc);
    	}
    
    	sock.Create(port,SOCK_DGRAM,servern);
    	sock.Connect(servern,port);
    
    	Sleep(200);
    	
    	//request for info would go here ---|
    	send = "ÿÿÿÿinfo\x00";
    	sock.Send(send,(int)strlen(send));
    	Sleep(200);
    	sock.Receive(buffer,4);	
    	for(int i=0;i<6;i++){
    		serverinfo[i]=this->Read();
    		MessageBox((LPCSTR)serverinfo[i],(LPCSTR)serverinfo[i]);
    	}
    
    	return true;
    feel free to comment on ineffeciency etc, its my first serious program

    yes im using mfc
    Attached Files Attached Files
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width