Advertisement
Guest User

Untitled

a guest
May 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1.  while(1) {
  2.         int size;
  3.         if ((size = recv(s, message, MAXLINE, 0)) > 0)  { // non-blocking read
  4.                 //size = recv(s, message, MAXLINE, 0);
  5.                 message[size] = '\0';
  6.         }
  7.         if (kbhit()) {
  8.             curpos.X = wherex(); // 원래 cursor 위치를 기억한다.
  9.             curpos.Y = wherey();
  10.             gotoxy(0, 22);
  11.             if(gets(message)) {
  12.                 sprintf(line, "%s\n", message);
  13.                 if (send(s, line, strlen(line)+1, 0) < 0)
  14.                     printf("Error : Write error on socket.\n");
  15.                 if (strstr(message, escapechar) != NULL ) {
  16.                     printf("Good bye.\n");
  17.                     closesocket(s);
  18.                     exit(0); 
  19.                 }
  20.             }
  21.             gotoxy(0, 22); 
  22.             memset(message, ' ', strlen(message)); // 마지막 message를 지운다.
  23.             printf("%s", message);
  24.             gotoxy(curpos.X, curpos.Y); // 원래 위치로 돌아간다.
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement