fixed network api bug! added MTU for send and receive (look at src)
[my-code/api.git] / network / network.c
index dc5164b..0862637 100644 (file)
@@ -255,7 +255,7 @@ int network_send(int fd,unsigned char *data,int datasize) {
   left=datasize;
 
   while(left) {
-    if((count=write(fd,data+datasize-left,left))==-1) {
+    if((count=write(fd,data+datasize-left,left<MTU?left:MTU))==-1) {
       perror("[network] write call");
       return N_ERROR;
     }
@@ -278,7 +278,7 @@ int network_receive(int fd,unsigned char *data,int datasize) {
   left=datasize;
 
   while(left) {
-    if((count=read(fd,data,datasize))==-1) {
+    if((count=read(fd,data+datasize-left,left<MTU?left:MTU))==-1) {
       perror("[network] read call");
       return N_ERROR;
     }