fixed network api bug! added MTU for send and receive (look at src)
authorhackbard <hackbard>
Tue, 16 Nov 2004 10:33:45 +0000 (10:33 +0000)
committerhackbard <hackbard>
Tue, 16 Nov 2004 10:33:45 +0000 (10:33 +0000)
network/network.c
network/network.h

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;
     }
index 4f5e87e..e80995d 100644 (file)
@@ -43,6 +43,8 @@
 
 #define MAX_LISTEN_QUEUE 32
 
+#define MTU 1448
+
 /* net specific variables */
 typedef struct s_connection {
   int fd;