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 25... Line 25...
25
struct net_tcpsocket *net_connect(const char *ip, unsigned short port);
25
struct net_tcpsocket *net_connect(const char *ip, unsigned short port);
26
 
26
 
27
/* checks whether or not a socket is connected. returns:
27
/* checks whether or not a socket is connected. returns:
28
 *  0 = not connected,
28
 *  0 = not connected,
29
 *  1 = connected
29
 *  1 = connected
30
 * -1 = error
30
 * -1 = error */
31
 *
-
 
32
 * if waitstate is non-zero, then net_isconnected() may release a few cpu
-
 
33
 * cycles (useful when net_isconnected() is used within a busy loop). */
-
 
34
int net_isconnected(struct net_tcpsocket *s, int waitstate);
31
int net_isconnected(struct net_tcpsocket *s);
35
 
32
 
36
/* Sends data on socket 'socket'.
33
/* Sends data on socket 'socket'.
37
Returns the number of bytes sent on success, and <0 otherwise. The error code can be translated into a human error message via libtcp_strerr(). */
34
Returns the number of bytes sent on success, and <0 otherwise. The error code can be translated into a human error message via libtcp_strerr(). */
38
int net_send(struct net_tcpsocket *socket, const char *line, long len);
35
int net_send(struct net_tcpsocket *socket, const void *line, long len);
39
 
36
 
40
/* 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.
37
/* 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.
41
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(). */
38
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(). */
42
int net_recv(struct net_tcpsocket *socket, char *buff, long maxlen);
39
int net_recv(struct net_tcpsocket *socket, void *buff, long maxlen);
43
 
40
 
44
/* Close the 'sock' socket. */
41
/* Close the 'sock' socket. */
45
void net_close(struct net_tcpsocket *socket);
42
void net_close(struct net_tcpsocket *socket);
46
 
43
 
47
/* Close the 'sock' socket immediately (to be used when the peer is behaving wrongly) - this is much faster than net_close(). */
44
/* Close the 'sock' socket immediately (to be used when the peer is behaving wrongly) - this is much faster than net_close(). */