2011-01-14 62 views
1

我可以從每呼應我的命令發送給它停止服務器?
這是我的代碼部分:使用套接字進行遠程登錄時可以禁用ECHO嗎?

Socket s = ConnectSocket(server, port); 

if (s == null) 
    return ("Connection failed"); 

int bytes = 0; 
string ret = ""; 

bytes = s.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None); 
ret = Encoding.ASCII.GetString(bytesReceived, 0, bytes); 
//ret="????!????BCM96358 xDSL Router\r\nLogin: " 
ret = ret.Substring(12); //Remove the telnet header: 255,253,1,255, 253, 33,255, 251, 1,255, 251, 3 
//IAC,DO,Echo, IAC,DO,Remote Flow Control, IAC,WILL,Echo, IAC,WILL,Suppress Go Ahead 

    request = "Admin\r\n"; 
    bytesSent = Encoding.ASCII.GetBytes(request); 
    s.Send(bytesSent, bytesSent.Length, 0); 

    bytes = s.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None); 
    ret = Encoding.ASCII.GetString(bytesReceived, 0, bytes); 
//ret = "Admin\r\nPassword: " 

回答

0

是什麼讓你覺得它呼應?使用Wireshark查看網絡級別正在發生的事情。我強烈懷疑回聲發生在客戶端,而不是服務器。

+0

母雞我通過telnet訪問它,我沒有得到這個響應。 – jullin 2011-01-14 14:01:57

1

對於我發送此序列已經解決了迴音的問題。

"\xFF\xFB\x01\xFF\xFB\x03" 

在換句話說,它是等於IAC WILL ECHO IAC WILL SUPPRESS-GO-AHEAD

相關問題