iv gotten prity far on my client. last bit to do is to change the parameter of a users location through an argument. but im stumped.
look at my code and see if you can help...
[delphi]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace ConsoleApplication1
{
public class Whois
{
static void Main(String[] args)
{
string strHost;
FileStream aFile = new FileStream("config.ini", FileMode.Open);
StreamReader sa = new StreamReader(aFile);
strHost = sa.ReadLine();
TcpClient client = new TcpClient();
//client = new N.Sockets.TcpClient();
client.Connect("whois.net.dcs.hull.ac.uk", 43);
StreamWriter sw = new StreamWriter(client.GetStream());
StreamReader sr = new StreamReader(client.GetStream());
try
{
sw.WriteLine(args[0]);
sw.Flush();
}
catch
{
Console.WriteLine("ERROR: No User Specified");
}
if (args.Length == 2)
{
try
{
sw.WriteLine(args[1]);
sw.Flush();
}
catch
{
Console.WriteLine("ERROR: No Location or user Specified");
}
//CHANGE LOCATION HERE
Console.WriteLine("Number of command line parameters = {0}", args.Length);
Console.Read();
}
else
{
//VIEW LOCATION HERE
// sw.Write(args[0] + args[1]);
// Console.WriteLine(sr.ReadToEnd());
Console.WriteLine(args[0] + " is in " + sr.ReadLine());
Console.WriteLine("Number of command line parameters = {0}", args.Length);
sw.WriteLine();
Console.Read();
}
}
}
}
[/delphi]
i think im almost there. its just a few lines in "//CHANGE LOCATION HERE" that i need to add to change it.
basically. in command prompt i type..
client.exe user01
and it returns "user01 is in the toilet"
or i can type
client.exe user01 "is in a shop"
which changes the location, so next time you type "client.exe user01" it returns "user01 is in a shop".
helphelphelphelp
look at my code and see if you can help...
[delphi]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace ConsoleApplication1
{
public class Whois
{
static void Main(String[] args)
{
string strHost;
FileStream aFile = new FileStream("config.ini", FileMode.Open);
StreamReader sa = new StreamReader(aFile);
strHost = sa.ReadLine();
TcpClient client = new TcpClient();
//client = new N.Sockets.TcpClient();
client.Connect("whois.net.dcs.hull.ac.uk", 43);
StreamWriter sw = new StreamWriter(client.GetStream());
StreamReader sr = new StreamReader(client.GetStream());
try
{
sw.WriteLine(args[0]);
sw.Flush();
}
catch
{
Console.WriteLine("ERROR: No User Specified");
}
if (args.Length == 2)
{
try
{
sw.WriteLine(args[1]);
sw.Flush();
}
catch
{
Console.WriteLine("ERROR: No Location or user Specified");
}
//CHANGE LOCATION HERE
Console.WriteLine("Number of command line parameters = {0}", args.Length);
Console.Read();
}
else
{
//VIEW LOCATION HERE
// sw.Write(args[0] + args[1]);
// Console.WriteLine(sr.ReadToEnd());
Console.WriteLine(args[0] + " is in " + sr.ReadLine());
Console.WriteLine("Number of command line parameters = {0}", args.Length);
sw.WriteLine();
Console.Read();
}
}
}
}
[/delphi]
i think im almost there. its just a few lines in "//CHANGE LOCATION HERE" that i need to add to change it.
basically. in command prompt i type..
client.exe user01
and it returns "user01 is in the toilet"
or i can type
client.exe user01 "is in a shop"
which changes the location, so next time you type "client.exe user01" it returns "user01 is in a shop".
helphelphelphelp
Last edited: