home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / tcpiptk / r0lib32 / readme < prev    next >
Text File  |  1999-05-11  |  6KB  |  125 lines

  1. *****************************************************************************
  2. * NOTE :                                                                    *
  3. *     The samples of R0LIB are similar to the samples for R0LIB32           *
  4. *****************************************************************************
  5. 1. include "r0lib.h"
  6.    include "nerrno.h"
  7.    These are the include files provided to you.
  8.  
  9. 2. int sock_init(void)
  10.         returns 0 for success else failure.
  11. This call is a must. sock_init() should be the first call
  12. before any other socket call is made. Internally sock_init()
  13. attaches to INET$ and prepares the library to do socket calls.
  14. If sock_init() fails, it means that INET$ (sockets.sys) is not
  15. loaded. Check your config.sys "device=" statement. Or execute
  16. command "inetver" at os/2 command prompt, it should return you
  17. TCP/IP version greater than 3.00.
  18.  
  19. 3. The following socket calls are available:
  20.  
  21.  int sock_init(void);
  22.  long socket(int, int,int);
  23.  long bind(int,char far *, int);
  24.  long connect(int, char far *, int);
  25.  long listen(int,int);
  26.  long accept(int, char far *, int far *);
  27.  long sendto(int, char far *, int, int, char far *, int);
  28.  long send(int, char far *, int, int);
  29.  long sendmsg(int, char far *, int);
  30.  long recvfrom(int, char far *, int, int, char far *, int far *);
  31.  long recv(int, char far *, int, int);
  32.  long recvmsg(int, char far *, int);
  33.  long shutdown(int, int);
  34.  long setsockopt(int, int, int, char far *, int);
  35.  long getsockopt(int, int, int, char far *, int far *);
  36.  long getsockname(int, char far *, int far *);
  37.  long getpeername(int, char far *, int far *);
  38.  unsigned long gethostid(void);
  39.  long soclose(int);
  40.  long ioctl(int, int, char far *, int);
  41.  long select(int far *, int, int, int, long);
  42.  
  43. The only difference between these calls and the ones described in
  44. tcp/ip programmer's reference is the return value. These calls
  45. return "long" instead of "int". The reason is to return the errno
  46. in case of an error condition.
  47.  
  48. "THE BSD VERSION OF SELECT IS NOT SUPPORTED IN THE R0LIB.LIB."
  49.  
  50. 4. How to interpret error number?
  51.    For example,
  52.         long rc;
  53.         rc = send(...);
  54.         if(rc < 0) {
  55.         /* this is the error condition case */
  56.         /* The rc will be like this: 0xffff0041 */
  57.         /* separate the two words : low = 0x0041, high=0xffff */
  58.         /* The errno is 0x0041 --- EHOSTUNREACH ( no route to host) */
  59.  
  60.         }
  61.         else {
  62.         /* This is the number of bytes sent successfully */
  63.         }
  64.  
  65.   You can write a small macro to separate the two words and
  66. return the errno from the return value.
  67.  
  68. 5. Link this r0lib32.lib into your final R0 application and you
  69. shall be ready to use it.
  70.  
  71.  
  72. **************************************************************
  73.  
  74. The FOLLOWING LINES ARE ADDED TO HELP IN TESTINIG R0LIB32.LIB
  75.  
  76. **************************************************************
  77.  
  78. To test r0lib32.lib we have to build test.sys (use makefile.sys) and add
  79. an entry for the device driver in config.sys,copy test.sys in \mptn\protocol,
  80. reboot the machine so that test.sys is loaded in memory.Now compile testini.c
  81. (use makefile.ini) and generate testini.exe.Now by running testini.exe
  82. the function test_server()(in driver.c) will be invoked which acts as a server
  83. and waits for the client at port no 5000.Compile and run the client
  84. program(client.c) on any other machine.
  85.  
  86. 1) The client sends 1k of data(all 'a') the server modifies the data
  87. (changes all 'a' to 'b'),sends the modified data to  the client,the client
  88. prints the data received from the server.
  89.  
  90. 2) The client sends a string(shiva) to the client using sendmsg() call, the
  91. server recevies it (by recvmsg() call) and sends another string( ganesha) to
  92. the client,the client recevies the string and prints it.
  93.  
  94. 3) The function test_server() tests the following calls in internet domain
  95.    socket(),bind(),listen(),accept(),send(),revc(),sendmsg(),recvmsg(),ioctl(),
  96.    setsockopt(),getsockopt(),getpeername(),getsockname(),gethostid(),
  97.    soclose(),shutdown(),sock_init(),
  98.    Rest of the socket call supported by r0lib32.lib are tested by the
  99.    function init().
  100.    Note: test_server() and other fucnction calls in init() are mutually
  101.    exclusive,i.e if we call test_server() in init() we have to comment rest
  102.    of the code in init(), else we comment only  test_server();
  103.  
  104. New function test_server() was added  to driver.c file,this function is invoked
  105. in the function init() and init() is invoked by calling Dosdevioctl()( in
  106. testini.c ) with CALL_INIT as one of its parameters.The function init()
  107. was earlier making all socket calls now it just calls test_server()
  108. and all the lines are commented.The test_server() can be modified so that
  109. it can act as a client but we have to take care of sstods coversions when
  110. ever we are using local variables(pointer),we have to use sstods as we have
  111. used in test_server() while passing the of local variables(pointer) to any
  112. function or when assigning a local pointer.
  113.  
  114. test_server opens a STREAM socket in the internet domain and waits for a
  115. client at port no 5000.The client program should be run from another machine,
  116. in the client program the ip address of the server machine which has test.sys
  117. is to be specified while filling the structure sockaddr_in.To compile the
  118. client program use makefile.cli.
  119.  
  120. The client program is ring3 program.In the server program we are trying
  121. to access the socket calls(i.e socket.sys) through r0lib32,usually we access
  122. socket call through tcpip32.dll(if 32 bit) or tcpipdll.dll(if 16 bit).Tcpbeui
  123. uses r0lib.lib.
  124.  
  125.