78 Chapter 2
Programming Examples
LAN Programming Examples
#ifdef WINSOCK
#include <windows.h>
# ifndef _WINSOCKAPI_
# include <winsock.h> // BSD-style socket functions
# endif
#else /* UNIX with BSD sockets */
# include <sys/socket.h> /* for connect and socket*/
# include <netinet/in.h> /* for sockaddr_in */
# include <netdb.h> /* for gethostbyname */
# define SOCKET_ERROR (-1)
# define INVALID_SOCKET (-1)
typedef int SOCKET;
#endif /* WINSOCK */
#ifdef WINSOCK
/* Declared in getopt.c. See example programs disk. */
extern char *optarg;
extern int optind;
extern int getopt(int argc, char * const argv[], const char* optstring);
#else
# include <unistd.h> /* for getopt(3C) */
#endif
#define COMMAND_ERROR (1)
#define NO_CMD_ERROR (0)