aboutsummaryrefslogtreecommitdiffstats
path: root/socket.h
blob: 10a0a974728a3a10ad4dc143aa2eb22e38c111d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * socket.h -- declarations for socket library functions
 *
 * Design and implementation by Carl Harris <ceharris@mal.com>
 *
 * For license terms, see the file COPYING in this directory.
 */

#ifndef SOCKET__
#define SOCKET__

/*
Create a new client socket 
returns (FILE *)NULL on error 
*/
FILE *Socket(char *host, int clientPort);

/* 
Get a string terminated by an '\n', delete any '\r' and the '\n'.
Pass it a valid socket, a buffer for the string, and
the length of the buffer (including the trailing \0)
returns 0 for success. 
*/
int SockGets(char *buf, int len, FILE *sockfp);

/*
Write a chunk of bytes to the socket.
Returns 0 for success.
*/
int SockWrite(char *buf, int len, FILE *sockfp);

/* 
Send formatted output to the socket, followed
by a CR-LF.
Returns 0 for success.
*/
#if defined(HAVE_STDARG_H)
int SockPrintf(FILE *sockfp, char *format, ...) ;
#else
int SockPrintf();
#endif
 
#endif /* SOCKET__ */