home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / r / rtg_master / rtgmasterv21.0dev.lha / demos / network / TCPClient.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-28  |  1.2 KB  |  46 lines

  1. #include <clib/exec_protos.h>
  2. #include <pragmas/exec_pragmas.h>
  3. #include <stdio.h>
  4. #include <strings.h>
  5. #include <rtgmaster/rtgmaster.h>
  6. #include <rtgmaster/rtgsublibs.h>
  7. #include <clib/rtgmaster_protos.h>
  8. #include <pragmas/rtgmaster_pragmas.h>
  9. #include <rtgmaster/rtgtcpip.h>
  10. #include <clib/dos_protos.h>
  11.  
  12. struct Library *SocketBase=0;
  13. struct Library *RTGMasterBase=0;
  14.  
  15. void makeservaddr(struct sockaddr_in *address, char *host, int port);
  16. struct RTG_Socket *LIBOpenClient(char *host, struct Library *SBase, int port, int mode, int protocol);
  17. struct RTG_Socket rs;
  18.  
  19. void main()
  20. {
  21.  struct RTG_Socket *s;
  22.  if (RTGMasterBase=OpenLibrary("rtgmaster.library",0))
  23.  {
  24.   if (SocketBase=OpenLibrary("bsdsocket.library",4))
  25.   {
  26.    int i;
  27.    long mode=1;
  28.    char buf[1024];
  29.    char buf2[1024];
  30.    char *strings[]={"Nur","ein","Test",NULL};
  31.    s=OpenClient(SocketBase,"194.55.101.26",3050,SOCK_STREAM,0);
  32.    RtgIoctl(SocketBase,s,&mode);
  33.    while(1)
  34.    {
  35.     if (RtgRecv(SocketBase,s,buf,0,25)>0)
  36.      printf("%s\n",buf);
  37.      sprintf(buf2,"Message from Socket ",s->s);
  38.     RtgSend(SocketBase,s,buf2,0,strlen(buf2)+1);
  39.    }
  40.    CloseLibrary(SocketBase);
  41.    CloseLibrary(RTGMasterBase);
  42.   }
  43.  }
  44. }
  45.  
  46.