]> hackdaworld.org Git - my-code/api.git/commitdiff
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 dc5164ba085e58d97d38032f4cdb96a419140308..0862637c2d6cc062bed20ae2b86fcecd08c00f33 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 4f5e87ebd0b8be7e1960f2fac3645dfbbc9e3603..e80995d93b4e051638591923fd771e8e0fdc13da 100644 (file)
@@ -43,6 +43,8 @@
 
 #define MAX_LISTEN_QUEUE 32
 
+#define MTU 1448
+
 /* net specific variables */
 typedef struct s_connection {
   int fd;