Posts

c - What does recv() return when using non-blocking sockets? -

if set socket non-blocking, should recv() if there no new data read? at moment, using , if statement see if received greater -1. seems block somehow if nothing received. code looks like: flags = fcntl(newfd, f_getfl); flags |= o_nonblock; fcntl(newfd, f_setfl, flags); while(1){ ... ... if( (recvbytes = recv(newfd, recvbuf, maxbuflen-1, 0)) > -1) { ... } } according manpage: if no messages available @ socket , o_nonblock not set on socket's file descriptor, recv() shall block until message arrives. if no messages available @ socket , o_nonblock set on socket's file descriptor, recv() shall fail , set errno [eagain] or [ewouldblock].

c# - How to integrate a Linq to Entity query that queries multiple entities in a repository and send data to View? -

i'm learning mvc, repository pattern , ef , need advice how best integrate method contains query queries multiple entities repository. at moment, have created repository class implements interface , uses instance of dbcontext retrieve data database using entity framework, 1 entity. edited... have getjourneys() method in repository, unsure how obtain journey details query in controller. can user details. public ienumerable<user> getjourneys() { var todaydate = datetime.now; //woking many many relationship //(join tables) in asp.net mvc/entity framework var viewmodel = j in dbcontext.users u in dbcontext.journeys u.departdate >= todaydate.date orderby u.departdate ascending select j; return viewmodel.tolist(); } below user entity public class user { [key, required] public int userid { get; set; } [maxlen...

sql server - Java Resultset Not Showing Unicode (Chinese) Characters, But Showing as Question Marks -

i have following issue. java resultset not showing unicode (chinese) characters, showing other characters. sure characters stored/showing in microsoft sql server (as nvarchar). so seems retrieving issue. here code: protected string getstringvaluenonulls(resultset rs, string colname) { string ret = rs.getstring(colname); ret = new string(ret.getbytes(), "utf8"); system.out.println(ret); ... output print statement: so (so in db) ??? (张先生 in db) ??????9999 ( 建国门外大街9999 in db) ?? (北京 in db) 100010 (100010 in db) it showing english/ascii characters not chinese characters. noticed number of chinese characters equal question marks replaces with. i have tried before plain getstring(), , doing getbytes() conversion both producing same results. is missing, or maybe issue driver? please help. ----------------i added connection, didn't help: class.forname("com.microsoft.sqlserver.jdbc...

c# - How to restart service remotely? -

i can start or stop service remotely .net project. connectionoptions options = new connectionoptions(); options.username = @"192.168.36.22\test"; options.password = "test"; managementscope scope = new managementscope(@"\\192.168.36.22\root\cimv2", options); scope.connect(); managementoperationobserver stop = new managementoperationobserver(); stop.completed += new completedeventhandler(stop_callback); try { string nameservices = "arcgis server"; wqlobjectquery query = new wqlobjectquery("select * win32_service name=\"" + nameservices + "\""); managementobjectsearcher find = new managementobjectsearcher(scope, query); foreach (managementobject spooler in find.get()) { spooler.invokemethod("stopservice", new object[] { }); spooler.invokemethod(start, "stopservice", new object[] { }); } } .... how can restart service? you use servicecontrol...

what is the best and how declare const in function of c++ -

i have these code #include <iostream> using namespace std; class ex; class exx; class ex { public: int _val; int const *_p_val; void setptrval(int * const &val) { _p_val=val; } }; class exx { public: ex const *_ex; void setex(ex const &ex) { _ex=&ex; } }; int main() { ex x; int i=10; x.setptrval(&i); exx xx; xx.setex(x); int y=20; cout<<*(xx._ex->_p_val)<<endl; x.setptrval(&y); cout<<*(xx._ex->_p_val)<<endl; cout<<*x._p_val<<endl; return 0; } 1: can see, ex x not const of ex class . , ex const *_ex; pointer point ex const . why above ok? 2: const in void setex(ex const &ex) means can't modify ex in function body? 3: how fix setter function member pointer variable if want prototype above (suppose sercurity reason)? ok. if ex const *_ex; become ex *_ex; so, in setter function, want prototype not mod...

php - Will Doctrine delete the object using remove() without calling flush()? -

in symfony2 application i've been running errors of type: e_error: allowed memory size of * bytes exhausted (tried allocate 32 bytes) that said, i'm in process of refactoring code, way i've found on how delete doctrine objects calling method remove() . according symfony's documentation: the method remove() notifies doctrine want delete row database, doctrine won't until call flush() my question is... can call remove() in same fashion use unset remove object memory? long don't call flush() ? if not, what's best way "unset" objects using "symfony way" things ? what looking telling doctrine stop referencing these objects php can free memory. not want remove database rows because php running out of memory ... read how detach entities , what different entities states , means.

javascript - How to play one video in jQuery tab and stop others? -

i have 4 jquery tabs, in each tab there 2 videos. how make 1 video play @ time , pause others? , how make video pause when switch new tab? this code jsfiddle /* play 1 video @ time */ $('video').bind('play', function() { activated = this; $('video').each(function() { if(this != activated) { this.pause(); } }); }); /* active tab */ var active = $( "#issuestabs" ).tabs( "option", "active" ); /* pause videos not in active tab*/ if (!active) { $("video").each(function(){ $(this).get(0).pause(); }); } can show me wrong? thanks! can use: $('.tab').on('click', function() { $('.tabcontent:hidden').find('video').each(function() { $(this).get(0).pause(); }); }); (where .tabcontent name of content panels hidden/shown, click function showed example since not know library using tabs.)