• winsock - slow sending/recv
    9 replies, posted
Hi. i've done a server that should be able to send really big files like avi-files but I can't ever send a 2 mb picture. I think 600kb is max or something before the sending begin to slow down as hell, the whole pc is lagging. I don't know if it's because of the server or the client. the package size is 1024 bytes. Do you know know why this happend? Is the package size too small? [editline]03:20AM[/editline] ok, the problem is the server, but i don't know what. I'll give you some bad ass code for you. [code] for (int x = 0; x < packages; x++) { if( lSize - (x * PACKAGE_SIZE) > PACKAGE_SIZE ) { package_official_size = PACKAGE_SIZE; } else { //package_official_size = 3; package_official_size = lSize - (x * PACKAGE_SIZE); } pFile = fopen(file_name,"rb"); fseek (pFile, PACKAGE_SIZE * x , SEEK_SET); //save to variable pBuffer = (char *) malloc (sizeof(char) *lSize); fread (pBuffer, package_official_size , 1, pFile); fclose(pFile); pFile = NULL; //1B SEND package size itoa(package_official_size,sendnumb,10); bytesSent = send(m_socket,sendnumb,PACKAGE_SIZE,0); //1C SEND package bytesSent = send(m_socket,pBuffer,PACKAGE_SIZE,0); } [/code]
I fixed it. damn malloc.
[QUOTE=likesoursugar;18831215]I fixed it. damn malloc.[/QUOTE] You should post your revised code. :3
why do people say that? i'm pretty sure no one has the same problem. ever since one person said it everyone jumps on the bandwagon and says it. "damn malloc" is all you need to know.
[QUOTE=efeX;18844393]why do people say that? i'm pretty sure no one has the same problem. ever since one person said it everyone jumps on the bandwagon and says it. "damn malloc" is all you need to know.[/QUOTE] You have no idea how frustrating it is to look for a solution to a problem, find a forum thread with the same problem, and find that the OP found the solution and never posted it. Happens to me all the time.
[QUOTE=Ortzinator;18844749]You have no idea how frustrating it is to look for a solution to a problem, find a forum thread with the same problem, and find that the OP found the solution and never posted it. Happens to me all the time.[/QUOTE] I have the same issue. :P That's why I asked about it, and it's always interesting to see what the OP did to revise his code and make it work.
well okay then.
If that's your current code, you're leaking like fuck.
pvtmalloc can help wheres he been lately
[QUOTE=jA_cOp;18849933]If that's your current code, you're leaking like fuck.[/QUOTE] I typically find getting it to work comes first and revision comes later. :haw:
Sorry, you need to Log In to post a reply to this thread.