some c# help please!

Join Discord

Far

tsniffer
Staff member
Developer
May 19, 2003
20,179
30
2,783
540
hey all. im in the process of creating a client/server app, ive just started and atm it simply acts like a whois client.

im trying to do something that seems very simple, but its turning out quite complicated. and i cant find any guides that suite what i need.

this is my code..

[delphi]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using N = System.Net;
using System.Net.Sockets;

namespace ConsoleApplication1
{

public class Whois
{
static void Main(String[] args)
{
System.IO.TextReader r = System.IO.File.OpenText(@"E:\input.txt");
string s = r.ReadToEnd();

TcpClient client = new TcpClient();
client = new N.Sockets.TcpClient();
client.Connect("whois.godaddy.com", 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");

}
Console.WriteLine(sr.ReadToEnd());
Console.ReadLine();
}
}
}
[/delphi]

basically, instead of having the "whois.godaddy.com" (the server address) in there, id like to be able to store it as a variable in a text file. so that i can change the server address without changing the source.

how do i do this?

ps. iv had to use delphi tags as i dont think we have c# tags.
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
I dont know c# but.. if you add a debug line to..

client.Connect("whois.godaddy.com", 43);

and then add a watch to the variable "s" and see what is inside it... if it says what ever is inside the txt file, which i fink it will then just go

client.Connect(s, 43);
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,179
30
2,783
540
thanks got that working now. not sure why (s, 43) wasnt working when i tried it before :/

will keep this thread open as im sure ill need more help on this as i go along.