/[LeafOK_CVS]/lbbs/src/tcplib.c
ViewVC logotype

Diff of /lbbs/src/tcplib.c

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

Revision 1.2 by sysadm, Mon Apr 28 03:31:00 2025 UTC Revision 1.3 by sysadm, Mon May 5 14:27:57 2025 UTC
# Line 6  void MsToTimeval(const int ms, struct ti Line 6  void MsToTimeval(const int ms, struct ti
6          tv->tv_usec = (ms - tv->tv_sec * TIME_CNV_RATIO) * TIME_CNV_RATIO;          tv->tv_usec = (ms - tv->tv_sec * TIME_CNV_RATIO) * TIME_CNV_RATIO;
7  }  }
8    
9  int TimevalToMs(const struct timeval *tv)  long int TimevalToMs(const struct timeval *tv)
10  {  {
11          return (tv->tv_sec * TIME_CNV_RATIO + tv->tv_usec / TIME_CNV_RATIO);          return (tv->tv_sec * TIME_CNV_RATIO + tv->tv_usec / TIME_CNV_RATIO);
12  }  }
# Line 143  done: Line 143  done:
143          return 0; /* 连接服务器成功 */          return 0; /* 连接服务器成功 */
144  }  }
145    
146  int DoConnect(const char *ip, const int port, const int msec)  int DoConnect(const char *ip, const in_port_t port, const int msec)
147  {  {
148          struct sockaddr_in sa;          struct sockaddr_in sa;
149          int conn_fd;          int conn_fd;
# Line 241  int SafeAccept(int sockfd, struct sockad Line 241  int SafeAccept(int sockfd, struct sockad
241          return conn_fd;          return conn_fd;
242  }  }
243    
244  int DoSendData(int sockfd, const void *buf, const size_t len, int msec)  long int DoSendData(int sockfd, const void *buf, const size_t len, int msec)
245  {  {
246          struct timeval tv;          struct timeval tv;
247          fd_set wset;          fd_set wset;
248          int rv;          int rv;
249          int wc;          ssize_t wc;
250    
251          MsToTimeval(msec, &tv);          MsToTimeval(msec, &tv);
252          FD_ZERO(&wset);          FD_ZERO(&wset);
# Line 267  int DoSendData(int sockfd, const void *b Line 267  int DoSendData(int sockfd, const void *b
267          return 0; /* nothing had sent */          return 0; /* nothing had sent */
268  }  }
269    
270  int DoRecvData(int sockfd, void *buf, const size_t len, int msec)  long int DoRecvData(int sockfd, void *buf, const size_t len, int msec)
271  {  {
272          struct timeval tv;          struct timeval tv;
273          fd_set rset;          fd_set rset;
274          int rv;          int rv;
275          int rc;          ssize_t rc;
276    
277          MsToTimeval(msec, &tv);          MsToTimeval(msec, &tv);
278          FD_ZERO(&rset);          FD_ZERO(&rset);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1