#ifndef _COC_UTIL_H_
#define _COC_UTIL_H_

#include <netinet/in.h>
#include "myc_buf.h"

#define COC_CMD_LEN 256
/* the follwing should be larger than 4x(largest array)+length of additional parameters */
#define COC_RES_LEN 50000

int CocCreateSockAdr(
    struct sockaddr_in *sockaddrPtr,    /* Socket address */
    const char *host,                   /* Host.  NULL implies INADDR_ANY */
    int port);                          /* Port number */
/*
  compose internet address
*/

void CocDelay(int msec);
/*
  system independent delay function with msec resolution
*/

int CocSend(int fd, char *buf, int size);
/*
  send a message
*/

int CocRecv(int fd, StrBuf *buf, int timeout, int *flag);
/*
  receive message
  if flag is NULL, a timeout generates an error
  else *flag is set to zero between the select and the recv command
*/

#define COC_SEP '\0'
#define COC_DELAYED '\1'
#define COC_ERR '\2'
#define COC_TRM '\3'
#define COC_SYN0 '\4'
#define COC_SYN1 '\5'
#define COC_MAGIC '\6'
#define COC_CLRLOG '\7'

#endif /* _COC_UTIL_H_ */
