Hello Salem, thank's for the reply.
I was thought that maybe there was a getclientbuffersize(). For now I'm using (and I will have to continue using) a variation of the beej guide 'sendall()' function. That's a simulation of a send process that I made for implement the function:
Code:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
int send(char* ,int );
int main()
{
FILE *arx;
char *bff=NULL;
int ta,tb,tl,q;
int total,restants,n;
int inc;
bool rm;
arx=fopen("test.txt","rb");
fseek(arx,0L,SEEK_END);
ta=ftell(arx);
fseek(arx,0L,SEEK_SET);
tl=0;
tb=27;
bff=(char*)malloc(sizeof(char)*tb);
inc=0;
rm=false;
while(tl<ta)
{
if(rm)
{
tb++;
bff=(char*)realloc(bff,sizeof(char)*tb);
rm=false;
}
for(q=0;q<tb;q++)
{
//if(feof(arx)!=0) {break;}
if(tl>=ta) {break;}
bff[q]=getc(arx);
tl++;
}
bff[q]='\0';
total=0;
restants=strlen(bff);
while(total<strlen(bff))
{
n=send(bff+total,restants);
if(!rm && n==strlen(bff))
{
inc=1;
rm=true;
}
if(n==-1) {break;}
total+=n;
restants-=n;
}
}
if(bff) {free(bff);}
send(NULL,0);
fclose(arx);
getch();
return 0;
}
int send(char* data,int t)
{
static char complert[1024]="";
int tb,q,bl=0;
char bff[10];
if(!data) {printf("%s",complert);return 0;}
(t<10) ? tb=t : tb=10;
for(q=0;q<tb;q++)
{
bff[q]=data[q];
bl++;
}
bff[q]='\0';
sprintf(complert,"%s%s",complert,bff);
return bl;
}
//linked/compiled with mingw & devcpp as a *.cpp
it works with sokets simply using the sokets 'send' function instead my simulation call
Code:
n=send(thesocket,bff+total,restants,0);
the modification is the buffer memory reallocation when the client's buffer is bigger than the server buffer, so I can send more bytes. The method is not completed because the server buffer is reallocated incrementing by 1, so if I could know the client buffer size I would be able to realloc at the exact size to optimze the sending process. Sure that I'm not be the first on think about that...
Feel free to use/modify/comment/criticyze that code I posted
Niara