सरल कार्य के लिए
सॉकेट के माध्यम से जोड़ने और बस भेजने और प्राप्त करने (जैसे टेलनेट की तरह इंटरफेस के साथ एक विशेष हार्डवेयर डिवाइस से कनेक्ट करने के रूप में) पाठ आदेश पर्याप्त हो सकता है।
आप टेलनेट भागने दृश्यों, चेहरा टर्मिनल अनुकरण को संभालने के लिए इंटरएक्टिव आज्ञाओं संभाल आदि कुछ पहले से ही परीक्षण किया कोड जैसे Minimalistic Telnet library from CodeProject (मुक्त) या कुछ व्यावसायिक टेलनेट/टर्मिनल एमुलेटर पुस्तकालय का उपयोग की आवश्यकता हो सकती है आप असली टेलनेट सर्वर से कनेक्ट करना चाहते हैं, (जैसे कि हमारे Rebex Telnet) आपको कुछ समय बचा सकता है।
कोड के बाद
(this url से लिया गया) से पता चलता है कि यह कैसे उपयोग करने के लिए:
// create the client
Telnet client = new Telnet("servername");
// start the Shell to send commands and read responses
Shell shell = client.StartShell();
// set the prompt of the remote server's shell first
shell.Prompt = "servername# ";
// read a welcome message
string welcome = shell.ReadAll();
// display welcome message
Console.WriteLine(welcome);
// send the 'df' command
shell.SendCommand("df");
// read all response, effectively waiting for the command to end
string response = shell.ReadAll();
// display the output
Console.WriteLine("Disk usage info:");
Console.WriteLine(response);
// close the shell
shell.Close();
स्रोत
2010-09-02 12:09:14