3692's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
New Members
Active Posts:
7 (0.02 per day)
Joined:
03-April 12
Profile Views:
979
Last Active:
User is offline Apr 25 2012 12:55 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   3692 has not set their status

Posts I've Made

  1. In Topic: Unable to open the file, send strings to the client side.

    Posted 5 Apr 2012

    public void Run()
                     {
                         try
                         {
                             StreamReader sr = new StreamReader("c:/myfile2.txt");
                             using (var reader = new StreamReader(_client.GetStream()))
                             
                             {
                                 string line ="";
                                 int lineNumber = 0;
                                 
    
                                 while (null != (line = sr.ReadLine()))
                                 {
                                     lineNumber += 1;
                                     byte[] data = new byte[1024];
                                     NetworkStream stream = _client.GetStream();
                                     //if (line.Equals(line))
                                     for (int ct = stream.Read(data,0, data.Length-1); 0 < ct; ct = stream.Read(data,0,data.Length-1))
                                       
                                         line += Encoding.ASCII.GetString(data, 0, ct);
                                     line = line.Trim();
    
                                     {
                                         lineNumber.ToString();
                                         
                                         data = Encoding.ASCII.GetBytes(line);
                                         _client.Client.Send(data, data.Length, SocketFlags.None);
                                         Console.WriteLine("Line {0} matches {1}", lineNumber, line);
                                     }
                                 }
    
                             }
                         }
                         catch (Exception ex)
                         {
                             Console.Error.WriteLine(ex.ToString());
                         }
                         Console.WriteLine("Closing client");
                         _client.Close();
    
    
                     }
                 }
    
    

    The debugger hits the code till here -->
    for (int ct = stream.Read(data,0, data.Length-1); 0 < ct; ct = stream.Read(data,0,data.Length-1))
    

    The values(strings) I pass from the client side(telnet) is not shown on the server side.. But while debugging it every line in the program, the values (message) appear in the console. Thank u so much for the link, could come till here only because of the link. :)
  2. In Topic: Checking for strings from a file using sockets.send method.

    Posted 4 Apr 2012

    View PostDimitriV, on 04 April 2012 - 12:13 AM, said:

    I hardly know C# either, I have only been learning C languages for a relatively little amount of time :)
    I think you may wish to use .Contains method within a string, then send either "contains" or "does not contain" back to the client ;)


    Oh ok.. :) Thank you so much anyway. :) I'll try using that. :)
  3. In Topic: Checking for strings from a file using sockets.send method.

    Posted 4 Apr 2012

    View PostDimitriV, on 04 April 2012 - 12:06 AM, said:

    Why are you just calling lineNumber.ToString?
    Also, it could be worth using this for the loop instead:
    While (!sr.EndOfStream) {
    //do stuff
    }
    
    

    Thank u so much DimitriV. I really appreciate your help. Its just been a month since i started learning c#. So could you please explain what does that do? And modify my program accordingly?
  4. In Topic: Checking for strings from a file using sockets.send method.

    Posted 3 Apr 2012

    View PostDimitriV, on 03 April 2012 - 11:50 PM, said:

    Have you encountered any issues? What's next for you to achieve?

    Yes I've encountered couple of problems. I'm unable to check for strings from the file. The file doesn't open when I try to execute the program. And when i give the request from the client side using telnet, the strings that are present in the file, should return to the client's side saying it is present. Else it should return not present. But this doesn't happen. What do i do? Could you please help me out?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

3692 has no profile comments yet. Why not say hello?