/[rdesktop]/jpeg/rdesktop/trunk/tcp.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /jpeg/rdesktop/trunk/tcp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by matty, Fri Sep 14 13:51:38 2001 UTC revision 33 by matty, Sat Sep 15 12:34:34 2001 UTC
# Line 56  tcp_send(STREAM s) Line 56  tcp_send(STREAM s)
56    
57          while (total < length)          while (total < length)
58          {          {
59                  sent = write(sock, s->data + total, length - total);                  sent = send(sock, s->data + total, length - total, 0);
   
60                  if (sent <= 0)                  if (sent <= 0)
61                  {                  {
62                          error("write: %s\n", strerror(errno));                          error("send: %s\n", strerror(errno));
63                          return;                          return;
64                  }                  }
65    
# Line 72  tcp_send(STREAM s) Line 71  tcp_send(STREAM s)
71  STREAM  STREAM
72  tcp_recv(int length)  tcp_recv(int length)
73  {  {
74          int ret, rcvd = 0;          int rcvd = 0;
         struct timeval tv;  
         fd_set rfds;  
75    
76          if (length > in.size)          if (length > in.size)
77          {          {
# Line 86  tcp_recv(int length) Line 83  tcp_recv(int length)
83    
84          while (length > 0)          while (length > 0)
85          {          {
86                  ui_process_events();                  ui_select(sock);
   
                 FD_ZERO(&rfds);  
                 FD_SET(sock, &rfds);  
                 tv.tv_sec = 0;  
                 tv.tv_usec = 100;  
   
                 ret = select(sock + 1, &rfds, NULL, NULL, &tv);  
87    
88                  if (ret)                  rcvd = recv(sock, in.end, length, 0);
89                    if (rcvd == -1)
90                  {                  {
91                          rcvd = read(sock, in.end, length);                          error("recv: %s\n", strerror(errno));
92                            return NULL;
                         if (rcvd <= 0)  
                         {  
                                 error("read: %s\n", strerror(errno));  
                                 return NULL;  
                         }  
   
                         in.end += rcvd;  
                         length -= rcvd;  
93                  }                  }
94    
95                    in.end += rcvd;
96                    length -= rcvd;
97          }          }
98    
99          return &in;          return &in;

Legend:
Removed from v.30  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC 1.1.26