Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c++ - Network send problem -


i try send data on network, server i've programmed doesen't data. code worked befor:

void mainwindow::send() {  qbytearray qbarr;  qdatastream qdstrm(&qbarr, qiodevice::writeonly);  int icount = qlist->count();  qprogressdialog qprogrsdsend(qstring("sending..."), qstring("cancel"), 0, icount, this);   qdstrm.setversion(qdatastream::qt_4_6);   qprogrsdsend.setwindowmodality(qt::windowmodal);   for(int = 0; < icount; i++)  {   if(qprogrsdsend.wascanceled())    break;    qdstrm << (quint16)0;   qdstrm << (*qlist)[i].data();   qdstrm.device()->seek(0);   qdstrm << (quint16)(qbarr.size() - sizeof(quint16));    qprogrsdsend.setvalue(i);    qtcpsoclient->write(qbarr);   qtcpsoclient->flush();   qtcpsoclient->waitforbyteswritten();    qbarr.clear();  }   qlblstatus2->settext("file send."); } 

but takes many time send each elemt qlist. tried modify methode, first elements qlist has been saved in qbarr. , send file. code doesnt work:

void mainwindow::send() {  qbytearray qbarr;  qdatastream qdstrm(&qbarr, qiodevice::writeonly);  int icount = qlist->count();  qprogressdialog qprogrsdsend(qstring("sending..."), qstring("cancel"), 0, icount, this);   qdstrm.setversion(qdatastream::qt_4_6);   qprogrsdsend.setwindowmodality(qt::windowmodal);   qdstrm << (quint16)0;   for(int = 0; < icount; i++)  {   if(qprogrsdsend.wascanceled())    break;    qdstrm << (*qlist)[i].data();    qprogrsdsend.setvalue(i);  }   qdstrm.device()->seek(0);  qdstrm << (quint16)(qbarr.size() - sizeof(quint16));   qtcpsoclient->write(qbarr);  qtcpsoclient->flush();  qtcpsoclient->waitforbyteswritten();   qbarr.clear();   qlblstatus2->settext("file send."); } 

and here methode use read data:

void qserverthread::onreadyread(void) {  if(read == false)  {   read = true;   emit reading(true);  }   while(!qtcpsoclient->atend())  {   qdatastream qdstrmin(qtcpsoclient);   qdatastream qdstrmout(qfile);   qbytearray qbarrdata;   quint16 qui16blocksize = 0;   int iversion = qdstrmin.version();    qdstrmin.setversion(iversion);   qdstrmout.setversion(iversion);    if(qtcpsoclient->bytesavailable() < (int)sizeof(quint16))    break;    qdstrmin >> qui16blocksize;    if(qtcpsoclient->bytesavailable() < qui16blocksize)    break;    qdstrmin >> qbarrdata;    qdstrmout << qbarrdata.data();    qfile->flush();  }   read = false;  emit reading(false); } 

i hope can me. thanks

paul

couldn't problem in server? suppose connect onreadyread readyread singal of socket. signal emitted once per chunk of data received. if send data @ once, possible signal gets emitted once. suppose qtcpsoclient socket. now, can see happening:

you ask bytesavailable() < somesize before data arrived yet. in case read size, break out right after , on next read lost size information , read garbage.

this might not problem before send multiple short messages, , every message managed arrive before asked data size. bug still there though.

on sidenote. in original client code - why did flush() , waitforbyteswritten() after every write? may reason why slow.

[edit: corrected based on sergey tachenov's comment]


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -