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:
feel free to comment on ineffeciency etc, its my first serious programCode: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;
yes im using mfc




Reply With Quote