#include <PalmOS.h>
#include <unix/sys_socket.h>

/* This library is (C)2002 by Aleksander Malinowski, Bradley University */
/* See also http://gdansk.bradley.edu/olekmali/ for more about author */
/* It may be used and redistributed free of charge under the GNU license*/
/* provided  that this copyright note is not removed.                   */

typedef struct {
    UInt16              AppNetRefnum;
    Int32               AppNetTimeout;      /* =SysTicksPerSecond() * timeout in Seconds; */
    NetSocketRef        socket;
    UInt16              sendreceiveflags;   /* =0 */
    Err                 error;
} AM_tcpip;

extern Err  AmNetLibLoad(AM_tcpip *S);

extern Err  AmNetLibConnect(AM_tcpip *S, const Char *hostname, const UInt16 port, const UInt16 tout);

extern Int16 AmNetLibSend(AM_tcpip *S, Char *buffer, UInt16 buflen);

extern Int16 AmNetLibRecv(AM_tcpip *S, Char *buffer, const int maxlen);

extern Int16 AmNetLibSendLine(AM_tcpip *S, Char *line);

extern Int16 AmNetLibRecvLine(AM_tcpip *S, Char *line, const int maxlen);

extern Err  AmNetLibClose(AM_tcpip *S);

extern Err  AmNetLibUnload(AM_tcpip *S);