send with big buffer
send with big buffer
Hello,
I have this problem, I am using this command send(cli_sock,buffer,i,0); with big buffers over 5000 bytes.
But there is a strange problem,with a sniffer, I read all TCP's packet that my DS sends, but the packets, with send of 5200 bytes, are 2 and they are same.
Why? can you help me?
Excuse me for my English.
I have this problem, I am using this command send(cli_sock,buffer,i,0); with big buffers over 5000 bytes.
But there is a strange problem,with a sniffer, I read all TCP's packet that my DS sends, but the packets, with send of 5200 bytes, are 2 and they are same.
Why? can you help me?
Excuse me for my English.
-
- Site Admin
- Posts: 1986
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: send with big buffer
send can and will return without sending all of the data you requested, you need to check for this and compensate.
Code: Select all
//---------------------------------------------------------------------------------
int sendData(int socket, int sendsize, char *buffer) {
//---------------------------------------------------------------------------------
while(sendsize) {
int len = send(socket, buffer, sendsize, 0);
if (len <= 0) break;
sendsize -= len;
buffer += len;
}
return sendsize <= 0;
}
Re: send with big buffer
Ok thanks Ill try. But the send works fine, if I use send(cli_sock,buffer,5000,0) it returns 5000. But with sniffer I can read 2 packets with same content.
Re: send with big buffer
Here's the test :
i = 5300;
The sniffer (only 3 packets for over 5200 bytes)
with same content.
i = 5300;
Code: Select all
int data_send;
for(data_send=0;data_send < i;data_send += res){
res = i - data_send;
if(res > 800)
res = 800;
res = send(cli_sock,&buffer[data_send],res,0);
if(res <= 0)
break;
}
res = data_send;
Code: Select all
TCP 840
TCP 1460
TCP 1460
Re: send with big buffer
your loop has some confusing logic - try wintermute's loop and see if it works as expected. I use a similiar loop in cquake and it works fine.
it is probably counter productive to cap the sends at 800 bytes in any case as it will drastically reduce your throughput.
it is probably counter productive to cap the sends at 800 bytes in any case as it will drastically reduce your throughput.
Re: send with big buffer
it is not working. Anyway thanks.
Re: send with big buffer
what about the client receiving the data? the ds tcp/ip stack has some weird window size issues so it may stop transmitting quickly if there are no acks - the data will be in the stack on the ds but waiting to transmit.
Re: send with big buffer
Im working on my hb fb4nds, and Im sending a picture, you can read here, the func fb_upload_profile_image.
It woks well sometimes. In the func fb_send_req I create the socket and http request, POST.
It woks well sometimes. In the func fb_send_req I create the socket and http request, POST.
Re: send with big buffer
I suspect your POST may be malformed. you need to be carefull about unaligned access to ints. x86 handles this fine, but the arm processors in the ds only support aligned access - 4 bytes for ints and 2 bytes for shorts.
here is an example of a potential problem:
since postdata is a "char *" this will return unreliable results if it is not 4 byte aligned. you will need to read the bytes individually and build the int off of the buffer.
here is an example of a potential problem:
Code: Select all
size_data = *((int *)postdata);
Re: send with big buffer
The HTTP POST is good. You can check, the alignment, in the func init_fb. Anyway thare are opcodes with translation in arm cpus.
Who is online
Users browsing this forum: Majestic-12 [Bot], Semrush [Bot] and 2 guests