home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / souper15.zip / SOURCE / SOCKET.H < prev    next >
C/C++ Source or Header  |  1996-05-18  |  2KB  |  75 lines

  1.  
  2. /***********************************************************************
  3.   module:       socket.h
  4.   program:      popclient
  5.   SCCS ID:      @(#)socket.h    1.5  4/1/94
  6.   programmer:   Carl Harris, ceharris@vt.edu
  7.   compiler:     DEC RISC C compiler (Ultrix 4.1)
  8.   environment:  DEC Ultrix 4.3 
  9.   description:  Definitions module for socket.c
  10.  ***********************************************************************/
  11.  
  12. #ifndef SOCKET__
  13. #define SOCKET__
  14.  
  15. #ifndef  INADDR_NONE
  16. #ifdef   INADDR_BROADCAST
  17. #define  INADDR_NONE    INADDR_BROADCAST
  18. #else
  19. #define  INADDR_NONE    -1
  20. #endif
  21. #endif
  22.  
  23. #ifndef NO_PROTO
  24. /*
  25. Create a new client socket 
  26. returns < 0 on error 
  27. */
  28. int Socket(const char *host, short clientPort);
  29.  
  30. /* Close the socket. */
  31. void SockClose(int s);
  32.  
  33. /* 
  34. Get a string terminated by an '\n', delete any '\r' and the '\n'.
  35. Pass it a valid socket, a buffer for the string, and
  36. the length of the buffer (including the trailing \0)
  37. returns 0 for success. 
  38. */
  39. int SockGets(int socket, char *buf, int len);
  40.  
  41. /*
  42. Send a nul terminated string to the socket, followed by 
  43. a CR-LF.  Returns 0 for success.
  44. */
  45. int SockPuts(int socket, char *buf);
  46.  
  47. /*
  48. Write a chunk of bytes to the socket.
  49. Returns 0 for success.
  50. */
  51. int SockWrite(int socket, void *buf, int len);
  52.  
  53. /*
  54. Read a chunk of bytes from the socket.
  55. Returns 0 for success.
  56. */
  57. int SockRead(int socket, void *buf, int len);
  58.  
  59. /* 
  60. Send formatted output to the socket, followed
  61. by a CR-LF.
  62. Returns 0 for success.
  63. */
  64. int SockPrintf(int socket, const char *format, ...);
  65.  
  66. /*
  67. Check socket for readability.  return 0 for not readable,
  68. >0 for readable.
  69. */
  70. int SockStatus(int socket, int seconds);
  71.  
  72. #endif /* #ifndef NO_PROTO */
  73.  
  74. #endif /* SOCKET__ */
  75.