Hi everyone,
I a newbie for C# programming, current I m given a project on server - clients system using C#. I able to come out with a multithreads server - clients system.
Now I need to record/keep track of the data that I send from the clients side to the server side.
May I know what program to use? As in must I use EVENT LOG? or just some Read/Write text that will add to the clients code?
I am lost, I really don't know what to do next..
Some samples or links that I can refer too will be good.
Thanks in advance.
Newbie; JDomo
Depending on the type of data, you may want a database, event log, or something else.
For what type of data, i still not so sure right now, but i need to so a demo type, so i guess i am using some string and int to display..
So i guess Event log will best suit my project?
So there is another question to event log, how am i going to link the client massage to the event log? As in i need to record down what i send to the server as for a counter checking purpose.
Here is my client program; hope anyone of you guys can give me a helping hand.
// Client Program
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Net.Sockets;
public class clnt {
public static void Main() {
try {
// Hot Key
Console.WriteLine("Command: ");
Console.WriteLine("Press [enter] after completed a string");
Console.WriteLine("Type [exit] to exit from the sever");
TcpClient tcpclnt = new TcpClient();
Console.WriteLine("\nConnecting to Server...");
Boolean running = true;
tcpclnt.Connect("127.0.0.1", 8001);
// use the ipaddress as in the server program, "127.0.0.1" is the default IPaddress.
Console.WriteLine("Connected");
//Console.Write("Enter the string to be transmitted : ");
while (running)
{
Console.Write("Enter the string to be transmitted : ");
String str = Console.ReadLine();
String recStr = "";
Stream stm = tcpclnt.GetStream();
ASCIIEncoding asen = new ASCIIEncoding();
byte[] ba = asen.GetBytes(str);
Console.WriteLine("Transmitting...");
stm.Write(ba, 0, ba.Length);
byte[] bb = new byte[100];
int k = stm.Read(bb, 0, 100);
for (int i = 0; i < k; i++)
//Console.Write(Convert.ToChar(bb[i]));
recStr = recStr + Convert.ToChar(bb[i]);
Console.WriteLine(recStr);
stm.Flush();
bb = null;
ba = null;
}
}
catch (Exception e) {
Console.WriteLine("Error..... " + e.StackTrace);
}
Console.ReadLine();
}
}
//
Sorry that I still don't know how to use window form. So hope you guys can help me by guiding me through using non window form.
Thanks in advance;
Newbie - Just started learning C# for the past 8 days
JDomo
Check log4net library.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks