Subversion Repositories SvarDOS

Rev

Rev 207 | Rev 333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 207 Rev 329
Line 66... Line 66...
66
 
66
 
67
  return(resultsock);
67
  return(resultsock);
68
}
68
}
69
 
69
 
70
 
70
 
71
int net_isconnected(struct net_tcpsocket *s, int waitstate) {
71
int net_isconnected(struct net_tcpsocket *s) {
72
  waitstate = waitstate; /* gcc warning shut */
-
 
73
  if (tcp_tick(s->sock) == 0) return(-1);
72
  if (tcp_tick(s->sock) == 0) return(-1);
74
  if (sock_established(s->sock) == 0) return(0);
73
  if (sock_established(s->sock) == 0) return(0);
75
  return(1);
74
  return(1);
76
}
75
}
77
 
76
 
78
 
77
 
79
/* Sends data on socket 'socket'.
78
/* Sends data on socket 'socket'.
80
   Returns the number of bytes sent on success, and < 0 otherwise */
79
   Returns the number of bytes sent on success, and < 0 otherwise */
81
int net_send(struct net_tcpsocket *socket, const char *line, long len) {
80
int net_send(struct net_tcpsocket *socket, const void *line, long len) {
82
  int res;
-
 
83
  /* call this to let Watt-32 handle its internal stuff */
81
  /* call this to let Watt-32 handle its internal stuff */
84
  if (tcp_tick(socket->sock) == 0) return(-1);
82
  if (tcp_tick(socket->sock) == 0) return(-1);
85
  /* send bytes */
83
  /* send bytes */
86
  res = sock_write(socket->sock, (void *)line, len);
84
  return(sock_write(socket->sock, line, len));
87
  return(res);
-
 
88
}
85
}
89
 
86
 
90
 
87
 
91
/* Reads data from socket 'sock' and write it into buffer 'buff', until end of connection. Will fall into error if the amount of data is bigger than 'maxlen' bytes.
88
/* Reads data from socket 'sock' and write it into buffer 'buff', until end of connection. Will fall into error if the amount of data is bigger than 'maxlen' bytes.
92
Returns the amount of data read (in bytes) on success, or a negative value otherwise. The error code can be translated into a human error message via libtcp_strerr(). */
89
Returns the amount of data read (in bytes) on success, or a negative value otherwise. The error code can be translated into a human error message via libtcp_strerr(). */
93
int net_recv(struct net_tcpsocket *socket, char *buff, long maxlen) {
90
int net_recv(struct net_tcpsocket *socket, void *buff, long maxlen) {
94
  int i;
-
 
95
  /* call this to let WatTCP handle its internal stuff */
91
  /* call this to let WatTCP handle its internal stuff */
96
  if (tcp_tick(socket->sock) == 0) return(-1);
92
  if (tcp_tick(socket->sock) == 0) return(-1);
97
  i = sock_fastread(socket->sock, (void *)buff, maxlen);
93
  return(sock_fastread(socket->sock, buff, maxlen));
98
  return(i);
-
 
99
}
94
}
100
 
95
 
101
 
96
 
102
/* Close the 'sock' socket. */
97
/* Close the 'sock' socket. */
103
void net_close(struct net_tcpsocket *socket) {
98
void net_close(struct net_tcpsocket *socket) {