Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net.Sockets;
- using System.IO;
- public class Whois {
- static void Main(string[] args) {
- string username = args[0];
- string location = string.Empty;
- string IP = "whois.net.dcs.hull.ac.uk";
- int port = 43;
- TcpClient client = new TcpClient();
- StreamWriter sw = new StreamWriter(client.GetStream());
- StreamReader sr = new StreamReader(client.GetStream());
- client.Connect(IP, port);
- try {
- //Read current location
- if (args.Length == 1) {
- sw.WriteLine(args[0]);
- sw.Flush();
- location = sr.ReadToEnd();
- Console.WriteLine(username + " is " + location);
- }
- //Write new location
- else if (args.Length > 0) {
- int i = 1;
- //Console.Write(username + " location changed to "); **Commented out as job done by line 37
- //Loop through array to get location
- while (i < args.Length) {
- //Console.Write(args[i] + " "); **Don't write to console, write to location string instead
- location = location + args[i];
- i++;
- }
- sw.Flush(); //## ISN'T WRITING NEW LOCATION TO SERVER
- //Console.WriteLine(username + " location successfully updated to " + location); *******TEMP COMMENT OUT TO TEST line 37
- Console.WriteLine(username + " location successfully updated to " + sr.ReadToEnd());
- }
- }
- catch {
- Console.WriteLine("No entries found for user " + username);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement