#ifndef SOCKET_H
#define SOCKET_H

/*
  INet Socket Code

  by Johnson Earls
  version 1.0
  created 9-Dec-90

  changed by cknight
  version 1.1
  [changed it to fit in with SpiderBot,
  also made it a linked-list implementation]
  2-Mar-91
*/

#define ERR_SOCKBADADDR     -0x0100
#define ERR_SOCKCANTCREATE  -0x0101
#define ERR_SOCKCANTCONNECT -0x0102
#define ERR_SOCKERRREAD     -0x0103
#define ERR_SOCKERRWRITE    -0x0104
#define ERR_SOCKSELECT      -0x0105
#define ERR_SOCKCLOSED      -0x0106

typedef struct sockrec {
  int sd;               /* socket descriptor */
  long data;            /* data used by calling program */
  struct sockrec *next;
} sockrec;

sockrec *socket_allocate(sockrec *, long);
sockrec *socket_deallocate(sockrec *, sockrec *);
int socket_connect(sockrec *, char *, int);
void socket_disconnect(sockrec *);
int socket_read(sockrec *, char **);
int socket_write(sockrec *, char *);
int socket_write_noret(sockrec *, char *);
int socket_ready(sockrec *);
int socket_wait(sockrec *, long, long);
int socket_wait_kbd(sockrec *, long, long);

#endif