home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / kn / linux / sock.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-12  |  2.1 KB  |  77 lines

  1.  
  2. /* 
  3. **    TEKlib
  4. **    (C) 2001 TEK neoscientists
  5. **    all rights reserved.
  6. **
  7. **    tek/kn/linux/sock.c
  8. **
  9. **    socket backend
  10. **
  11. */
  12.  
  13. #include <sys/socket.h>
  14. #include <sys/time.h>
  15. #include <netinet/in.h>
  16. #include <arpa/inet.h>
  17. #include <unistd.h>
  18. #include <fcntl.h>
  19. #include <errno.h>
  20.  
  21. #include "tek/kn/exec.h"
  22. #include "tek/kn/sock.h"
  23. #include "tek/kn/linux/exec.h"
  24.  
  25.  
  26. #define KNSOCK_MAXLISTEN        64                /* max number of connections to a server socket */
  27. #define KNSOCK_MAXPENDING        64                /* max number of concurrent messages on a client socket pending for delivery */
  28. #define TIMEOUT_USEC            1000            /* select() timeout */
  29. #define KNSOCK_SENDFLAGS        MSG_NOSIGNAL
  30. #define KNSOCK_RECVFLAGS        MSG_NOSIGNAL
  31.  
  32.  
  33.  
  34. typedef int kn_sockenv_t;
  35.  
  36.  
  37. #include "tek/kn/sockcommon.h"
  38.  
  39.  
  40. int kn_waitselect(kn_sockenv_t *sockenv, int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t, TKNOB *evt, TBOOL *signal)
  41.     int numready = select(n, r, w, e, t);
  42.     *signal = kn_timedwaitevent(evt, TNULL, TNULL);
  43.     return numready;
  44. }
  45.  
  46. #define kn_getsockenv(sockenv)            TTRUE
  47. #define kn_locksock(sockenv)            
  48. #define kn_unlocksock(sockenv)            
  49. #define kn_getsockerrno(sockenv,desc)    errno
  50.  
  51. #define kn_inet_ntoa(name)                inet_ntoa(((struct sockaddr_in *) name)->sin_addr)
  52. #define kn_closesocket(desc)            close(desc)
  53. #define kn_socknonblocking(desc)        { int mode; mode = fcntl(desc, F_GETFL, 0); fcntl(desc, F_SETFL, mode | O_NONBLOCK); }
  54.  
  55.  
  56. #include "tek/kn/sockcommon/initsockname.c"
  57. #include "tek/kn/sockcommon/destroysockname.c"
  58. #include "tek/kn/sockcommon/cmpsockname.c"
  59. #include "tek/kn/sockcommon/dupsockname.c"
  60. #include "tek/kn/sockcommon/getsockname.c"
  61. #include "tek/kn/sockcommon/getsockport.c"
  62.  
  63. #include "tek/kn/sockcommon/createclientsock.c"
  64. #include "tek/kn/sockcommon/destroyclientsock.c"
  65. #include "tek/kn/sockcommon/getclientsockmsg.c"
  66. #include "tek/kn/sockcommon/putclientsockmsg.c"
  67. #include "tek/kn/sockcommon/waitclientsock.c"
  68.  
  69. #include "tek/kn/sockcommon/createservsock.c"
  70. #include "tek/kn/sockcommon/destroyservsock.c"
  71. #include "tek/kn/sockcommon/getservsockmsg.c"
  72. #include "tek/kn/sockcommon/returnservsockmsg.c"
  73. #include "tek/kn/sockcommon/waitservsock.c"
  74.  
  75. #include "tek/kn/sockcommon/itoa.c"
  76.