BlueChip

Members
  • Content count

    353
  • Joined

  • Last visited

Community Reputation

100 Neutral

About BlueChip

  • Rank
    Member
  1. thank you Kylotan, I've tried some tests, and StopConnection is set to 1 also if I don't touch any key....but now I've some informations in order to star a new research...
  2. this means that I enter in this code if I push some keyboard keys? or if a string is send to screen output? thanks...
  3. Hi! I'm studing sockets, but there is a piece of code that I don't undestand: for(;;) { rdset=all; do { ris=select(maxfd+1,&rdset,NULL,NULL,NULL); } while( (ris<0) && (errno==EINTR) ); if(ris<0) { perror("select failed: "); exit(1); } else { - OMISSIS - if( FD_ISSET(0,&rdset) ) { char str[100]; fgets(str,100,stdin); pthread_mutex_lock( &mutex_blocca ); StopConnection=1; pthread_mutex_unlock( &mutex_blocca ); } } } what does this line "if( FD_ISSET(0,&rdset) )" ?? when running code go in it? what I must do to enter in that 'if'?? 0 is not a socket? true? the main problem is that my application always enter in that 'if statement' and always StopConnection is set to 1, and this very very bad! can you help me? Thank you so much
  4. Quote: I'd suggest initially splitting the data to send equally across all 4 channels. Once one channel runs out of data to send, split the biggest piece of remaining data in two, and give the second half of it to the now empty connection. Repeat until the remaining data chunks are so small they aren't worth splitting. That will get the job done reasonably quickly, and a better splitting algorithm (based on say the average transfer rates so far) might get you a bit more speed. this is a good idea... i'll try it!! thanks :)
  5. Good morning... Quote: the server might be vaporized in a nuclear explosion Quote: (lightening strike, the coming of the 4 horsemen of the apocalypse, etc.) funny boys... I like my server... I don't want to lose it... ehmm... otherwise, I'm interesting about this Quote: You can have server send back acks, which allow you to estimate round trip time. I know how a TCP connection works , but I believed that acks were invisible to user. You tell me that I can see them for calculate rtt? Can you give me some tips?? thanks again :)
  6. Hi boys... and girls.. I've a question: You suppose that I've a client that opens 4 TCP connections with one (or more) server. For some reasons, a connection can be congested, or can be slow than another. there is a way to choose on which channel I must send the packets, in order to send all data in few time? for example, if my 2nd channel buffer is full, then I'll use another channel... this is an easy chosen... but if my 2nd channel buffer is not full, but the net is slow, or if the problem is on server side, (because server cpu is very busy) how my client can see that (in this moment) that channel is not the better choice?? i.e: sends 1st packet on 1st channel... sends 2nd packet on 1st channel... the packet leaves, but it ends in the server socket buffer tail.. my client sends the 3rd packet on 2nd channel... I hope that this problem is clear.. thanks and bye bye
  7. Problems with socket (unix)

    ok... I'll do something like this.. FD_ZERO(&temp); maxfd=0; for(i=0;i<2;i++) { if(maxfd<socketfd[i]) maxfd=socketfd[i]; FD_SET(socketfd[i],&temp); } if(maxfd<listenfd) maxfd=listenfd; FD_SET(listenfd,&temp); for(;;) { rdset=temp; but the 'writer code' is better put it after the reading operation, or under a its if guardian like this if( (socketfdactive[i]) && (FD_ISSET(socketfd[i],&rdset )) ) ?
  8. Hi! My goal is code PROXYTEST, an application that takes data from an entering TCP connection, and then sends them from 2 outing TCP connection. I'm studing I/O MULTIPLEXING, but, maybe, I've not undertood it, because in my application, there are some errors... but I don't see them... can you help me??? the error (or errors) is not a syntax error, but a conceptual error... --omissis-- here there is the code that calls socket, calls bind, calls listening, connect, etc. now, I've 1 socket in listen mode, and 2 socket in connect mode. --omissis-- //I prepare the neccesry for SELECT FD_ZERO(&rdset); maxfd=0; for(i=0;i<2;i++) { if(maxfd<socketfd[i]) maxfd=socketfd[i]; FD_SET(socketfd[i],&rdset); } if(maxfd<listenfd) maxfd=listenfd; FD_SET(listenfd,&rdset); for(;;) { do { ris=select(maxfd+1,&rdset,NULL,NULL,NULL); } while( (ris<0) && (errno==EINTR) ); if(ris<0) { perror("PROXY: select failed: "); exit(1); } else { //THIS WORK FINE.. ACCEPTS THE ENTERING CONNECTION if( (listenfdactive) && (FD_ISSET(listenfd,&rdset )) ) { do { memset (&Client, 0, sizeof (Client)); len = sizeof (Client); connectedfd = accept( listenfd, (struct sockaddr *) &Client, &len); } while ( (connectedfd<0) && (errno==EINTR) ); if (connectedfd < 0 ) { perror("accept() failed: \n"); exit (1); } else { if(maxfd<connectedfd) maxfd=connectedfd; FD_SET(connectedfd,&rdset); connectedfdactive = 1; } close(listenfd); listenfdactive=0; FD_CLR(listenfd,&rdset); } //THIS DOESN'T WORKS VERY WELL :( if( (connectedfdactive) && (FD_ISSET(connectedfd,&rdset )) ) { nread=LENMSG; memset(&msg,0,LENMSG); //READ LENMSG BYTES, I.E A COMPLETE MESSAGE do { ris=read(connectedfd, (char*)&msg,nread); } while ( (ris<0) && (errno==EINTR) ); if(ris<0) { perror("PROXY:read failed: "); fflush(stdout); return (0); } else if(ris==0) { //ALL DATA READ close(connectedfd); FD_CLR(connectedfd, &all); connectedfdactive = 0; fflush(stdout); } else { //A MESSAGE IS READ, SO I SEND IT THROUGH 1st //or 2nd OUTING SOCKET. NOW I USE ONLY ONE SOCKET nwrite=LENMSG; n = write(socketfd[0], &(msg), nwrite); if (n != nwrite) { printf ("Writen() failed \n"); fflush(stdout); return (1); } } this code seems tha read all entering bytes, but write few outing bytes, and then give a write error. I've tried to add this code after for(;;), instead of to put it after the reading operation, but seems that (FD_ISSET(socketfd[i],&rdset ) is never true. Select function doesn't wake up connected socket file descriptor if there are data in msg buffer. for(i=0;i<2;i++) { if( (socketfdactive[i]) && (FD_ISSET(socketfd[i],&rdset )) ) { nwrite=LENMSG; n = Writen(socketfd[i], &(msg), nwrite); if (n != nwrite) { printf ("Writen() failed \n"); fflush(stdout); return (1); } fflush(stdout); } } can you see what I wrong?? thaks!! :)
  9. I'm without words... thank you erissian!!! excellent lesson... now is all clear!! I thought that 'all' or 'app' were a commands... and not labels :) because I found them in more makefile on the net... thanks again! now I go to test my new knowledge!! goodbye
  10. oh yeah!! google is always a good choise!! :) now I've understaood what .o is, and what mean this syntax: Starter.o: Starter.c appdefs.h Util.h gcc -c ${GCCFLAGS} Starter.c but I still do not understand this code: Starter.exe: Starter.o Util.o gcc -o Starter.exe ${GCCFLAGS} ${LINKERFLAGS} Starter.o Util.o Does starter.exe needs Util.o because in starter.c is included util.h? And what is means? all: Apps MasterCow.exe Apps: Starter.exe Endless.exe that MasterCow.exe is the most important .exe, with special skills? and that Starter.exe Endless.exe are two .exe with less things? PS: in this web site http://www.opussoftware.com/tutorial/TutMakefile.htm, on unix world, often the .exe files are use, but is not said the cause... so, unix uses exe file, too??
  11. Hi people, I would want to try to make a very simple and short game on linux, for personal experience. coding the program is easy... the language is the same than windows OS... but I've some problems in compiling phase... I've caught from the net a makefile in order to have an idea... but there aren't comments and I don't understand some points. if is not too long, can you translate to me, step by step? My comments are written with capslock activated. (PS: I use knoppix and gcc) GCCFLAGS= -Wall -pedantic -ggdb LINKERFLAGS=-lpthread all: Apps MasterCow.exe Apps: Starter.exe Endless.exe Sender.exe: Starter.o Util.o gcc -o Starter.exe ${GCCFLAGS} ${LINKERFLAGS} Starter.o Util.o Sender.o: Starter.c appdefs.h Util.h gcc -c ${GCCFLAGS} Starter.c Receiver.exe: Endless.o Util.o gcc -o Endless.exe ${GCCFLAGS} ${LINKERFLAGS} Endless.o Util.o Receiver.o: Endless.c appdefs.h Util.h gcc -c ${GCCFLAGS} Receiver.c Ritardatore.o: MasterCow.c appdefs.h Util.h gcc -c ${GCCFLAGS} MasterCow.c Ritardatore.exe: MasterCow.o Util.o gcc -o MasterCow.exe ${GCCFLAGS} ${LINKERFLAGS} Util.o MasterCow.o Util.o: Util.c gcc -c ${GCCFLAGS} Util.c THIS IS EASY, IT REMOVES BOTTOM FILES, BUT WHY REMOVE .EXE FILE?? THESE ARE THAT I WANT, RIGHT??? clean: rm -f core* rm -f *.exe rm -f Starter.o Starter.exe rm -f Endless.o Endless.exe rm -f MasterCow.o MasterCow.exe rm -f Util.o thanks friends
  12. I see.... very strange... I use june 2007 SDK... and object 'ID3DXConstantTable' exists... but if I try to call 'GetSamplerIndex' I get this error C2039: 'GetSamplerIndex' : is not a member of 'ID3DXConstantTable' mmmm... I'll install SDK again...
  13. dark... I don't see the light again... I've tried, but I've got a surprise.... ID3DXConstantTable::GetSamplerIndex doesn't exist :( there was, but now ID3DXConstantTable has: GetBufferPointer GetBufferSize GetConstant GetConstantByName GetConstantDesc GetDesc SetBoolArray SetFloatArray SetInt SetIntArray SetMatrix SetMatrixArray SetMatrixPointerArray . SetMatrixTranspose SetMatrixTransposeArray SetMatrixTransposePointerArray SetValue SetVector SetVectorArray probably I've not understood jollyjeffers's explaining.... someone can give me more clues... thanks again
  14. thanks jollyjeffers, finally, now all is clear... now I go to add SetTexture((GetSamplerIndex(mytexturen),n) and I'll see if I've realy underst00d...