0

i'll start typing a command in the telnet module to communicate with my telnet server after i've already been connected and the server will suddenly drop me, exit telnet, and bring up the cmd prompt. what in this code is doing this?

void do_handleclient(int connsock,struct sockaddr_in *client_addr) {
  // Communicating with our new friend.
  string buffer, execmd;
  char filename[25000];
  int b=0, n=1, nstr=0, str=0;
  string sendbuf;
  char *cbuff=(char*)sendbuf.c_str();

  while(n!=0)
	  n=recv(connsock,cbuff,25000-1,0);
  while(cbuff[nstr]!=' ') { 
	  execmd[nstr]=cbuff[nstr];
	  nstr++;
  }
  while(cbuff[nstr]!='\r' || cbuff[nstr]!=' ') {
	  filename[str]=cbuff[str];
	  nstr++;
  }
  
  ifstream fd;
  fd.open(filename, ifstream::in);
  int length;
  while(1) {
      fd.read(cbuff,25000); // Reading the textfile.
	  fd.seekg(0,ios::end);
	  length=fd.tellg();
	  fd.seekg(0,ios::beg);
	  //if(length=0)               // EOF.
	  //    break;
      if(send(connsock,cbuff,length,0)==-1) 
          break;
  }
}
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by GPXtC02
-1

I can send messages on lan on local but I cann't send messages on internet on global. please help me. do you have a source of sending messages on global on internet?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.