Click to See Complete Forum and Search --> : help needed ... how to prevent the TCP server to read from the buffer ? pls read on..
shigehiro
June 6th, 2003, 03:43 AM
hi,
i encounter a prob when i m doing my TCP appl research project. Basically, we know that TCP server will receive the data,received from the client, from its socket thru the code :
AmountRead = recv(ConnSock,Buffer,sizeof(Buffer) ,0);
After that, it ll read the data from the buffer, right?
Now, my problem is that: i dun want the server to read the data from the buffer. Therefore, after sometimes the server receive its data from socket, the buffer will become full ( due to limited size of buffer we assigned earlier to buffer).Because the buffer is full already, it will start to drop the package it receive.
So, my question is : is it possible or any code that prevents server to read from its buffer? So far, i cant find the way yet.Thanks...
Really look forward for the reply. Thankz...
:)
filthy_mcnasty
June 6th, 2003, 04:49 AM
i'm not sure what you mean by "not read the data".
if you're the server you can throw the data on the socket aside after it's received but it's still read into the buffer.
or do you not want the data to ever hit the server? if so you can look into an api hook on the recv function that doesn't forward the buffer.
shigehiro
June 6th, 2003, 05:02 AM
wat i mean is that : i want to fill up the advertisement window for the server side,for eg:
initially , the server advertises the win =17920
then after the client sends the some packages to server, ( we do sth to the server side) , the window size ll decrease, because the server nv read the data from the buffer ( so the window size ll become smaller and smaller n' the buffer ll start to exhausted, and package sent by client ll start to drop),so, it means that " it never reach the server's appl, but got the chance to go to server's buffer)
hehehe
hope u understand wat i mean :rolleyes: :confused:
Shigehiro
:p
Shigehiro
dimm_coder
June 6th, 2003, 10:16 AM
Ha... If U send data through TCP connection , then if the recv buffer is full TCP on server side send a acknowledgement with win = 0 and client cannot send any data (it can only send empty packets to force TCP server side to send new win size) when server side TCP win !=0 it send ack with win = size and then client can send data. It sends all non-acknowledge data. So what I want to say that U cannot lose any data if U use TCP of course.
Also U mean that server reads data slower than TCP stack gets it?
Anyway U cannot lose data by TCP connection.
Mathew Joy
June 7th, 2003, 08:17 AM
dimm is right. TCP/IP is meant to guarentee delivery. The TCP/IP stack will not give you a byte if it has not given you the preceeding bytes that the client sent. As dimm said if the buffer is full, then the window size becomes 0, there by effectively pausing the send().
shigehiro
June 7th, 2003, 10:48 AM
Yeah.. the TCP server shld read the data from the stack /buffer slower than it receives the data. And i also aware that TCP is a connection oriented service (COS), thus there will not any data loss if we are using TCP. Maybe, i ll clarify this issue with my supervisor, since there is ambiguous about this problem. hehehehe... However, thanks for all your suggestion . I am really appreciate it. LL get back to u guys about this issue.
Thanks.
:')
Ciaooo...
Shigehiro
shigehiro
June 9th, 2003, 03:16 AM
okie...,
what my sup said is that: after the buffer become full/ win size =0, either the server or the client will terminate the connection.
Therefore, does anyone have any idea about how to implement that ? how to check whether the buffer has become full or not?
Thankz..
Shigehiro:cool: :rolleyes: :D
dimm_coder
June 9th, 2003, 03:30 AM
Originally posted by shigehiro
okie...,
what my sup said is that: after the buffer become full/ win size =0, either the server or the client will terminate the connection.
Therefore, does anyone have any idea about how to implement that ? how to check whether the buffer has become full or not?
Thankz..
Shigehiro:cool: :rolleyes: :D
Does your sup has expirience with TCP/IP?
For me seems is a bad solution. For TCP/IP is a "normal" situation however. "Normal" in that case that not critical. If server reads data slower that TCP stack gets it is not "the end of world", after it ends reading TCP can send data again, but U want to kill it.
It is better to think about optimization of client and server side algorithms for send/recv. Size of buffers, ... .
So for me it is not clear why your sup want to close a connection in that case.
shigehiro
June 9th, 2003, 03:37 AM
As what i posted earlier... :D .The TCP server-client application is for research purpose. Our institute has developed our own IP technology, thus, he need to validation of that TCP based on RFC 2525.Nah.. one of the 18 described problems in that RFC requires him to create a scenario which the server will read data from buffer slower than it receives it, so the win size=0. Now, i need to modify my program for that purpose. So , any idea?
Shigehiro
Mathew Joy
June 9th, 2003, 03:43 AM
In that case you have to use raw sockets. You can check if win=0 and terminate the connection.
shigehiro
June 9th, 2003, 03:45 AM
okie... i ll try using the raw socket... :D
If got problem, then i ll get back to u guys ...
shigehiro
June 9th, 2003, 03:58 AM
huah....:o :o .
i found out that using raw protocol, need to do a lot of things and quite troublesome..( must use IP_HDRINCL (raw IP) and build my own IP and TCP or UDP headers.). is there another way, that is easier than using raw protocol approach?
Mathew Joy
June 9th, 2003, 04:47 AM
Well, if you know the size of the buffer (or you can set), you can use MSG_PEEK while using recv so the recvd data is not being removed from the buffer. If the return value is equal to the size of the buffer then the buffer is full and terminate the connection. I'd also add that MSG_PEEK is bad and at times (I've read reports) that it causes problems. And the return value may not be accurate always. Check for your self. If it doesn't cause probles then OK(since it not for an application I guess it is OK).
shigehiro
June 9th, 2003, 09:25 AM
okie i ll try that :D
shigehiro
June 9th, 2003, 10:47 PM
okie .. thanks a lot.... i think i can implement liao....
:D
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.