tcpsend02.c 592 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "unp.h"
  2. int
  3. main(int argc, char **argv)
  4. {
  5. int sockfd;
  6. if (argc != 3)
  7. err_quit("usage: tcpsend02 <host> <port#>");
  8. sockfd = Tcp_connect(argv[1], argv[2]);
  9. Write(sockfd, "123", 3);
  10. printf("wrote 3 bytes of normal data\n");
  11. sleep(1);
  12. Send(sockfd, "4", 1, MSG_OOB);
  13. printf("wrote 1 byte of OOB data\n");
  14. sleep(1);
  15. Write(sockfd, "56", 2);
  16. printf("wrote 2 bytes of normal data\n");
  17. sleep(1);
  18. Send(sockfd, "7", 1, MSG_OOB);
  19. printf("wrote 1 byte of OOB data\n");
  20. sleep(1);
  21. Write(sockfd, "89", 2);
  22. printf("wrote 2 bytes of normal data\n");
  23. sleep(1);
  24. exit(0);
  25. }