2010-02-02 23:20:29 +00:00
|
|
|
/** \file shared/sockets.h
|
|
|
|
|
* Socket functions available to server and clients.
|
|
|
|
|
*/
|
|
|
|
|
|
1999-12-09 23:15:14 +00:00
|
|
|
#ifndef SOCKETS_H
|
|
|
|
|
#define SOCKETS_H
|
|
|
|
|
|
1999-12-11 19:21:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2005-05-21 14:55:46 +00:00
|
|
|
# include "config.h"
|
1999-12-11 19:21:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
1999-12-09 23:15:14 +00:00
|
|
|
#ifndef LCDPORT
|
2005-05-21 14:55:46 +00:00
|
|
|
# define LCDPORT 13666
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SHUT_RDWR
|
|
|
|
|
# define SHUT_RDWR 2
|
1999-12-09 23:15:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Connect to server on host, port */
|
2000-03-30 20:28:01 +00:00
|
|
|
int sock_connect (char *host, unsigned short int port);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Disconnect from server */
|
2000-03-30 20:28:01 +00:00
|
|
|
int sock_close (int fd);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Send printf-like formatted output */
|
2005-05-21 14:55:46 +00:00
|
|
|
int sock_printf (int fd, const char *format, .../*args*/);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Send lines of text */
|
2000-03-30 20:28:01 +00:00
|
|
|
int sock_send_string (int fd, char *string);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Send raw data */
|
2000-03-30 20:28:01 +00:00
|
|
|
int sock_send (int fd, void *src, size_t size);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Receive a line of text */
|
|
|
|
|
int sock_recv_string (int fd, char *dest, size_t maxlen);
|
|
|
|
|
/** Receive raw data */
|
2000-03-30 20:28:01 +00:00
|
|
|
int sock_recv (int fd, void *dest, size_t maxlen);
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2010-02-02 23:20:29 +00:00
|
|
|
|
|
|
|
|
/** Return the error message for the last error occured */
|
2003-08-06 12:11:54 +00:00
|
|
|
char *sock_geterror(void);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Send an already formatted error message to the client */
|
2005-07-17 16:14:07 +00:00
|
|
|
int sock_send_error(int fd, char* message);
|
2010-02-02 23:20:29 +00:00
|
|
|
/** Print printf-like formatted output to logfile and send it to the client */
|
2005-07-17 16:14:07 +00:00
|
|
|
int sock_printf_error(int fd, const char *format, .../*args*/);
|
2003-08-06 12:11:54 +00:00
|
|
|
|
1999-12-09 23:15:14 +00:00
|
|
|
#endif
|