我有這台設備的維護書,上面有修改設備出廠ip地址的指令,還有回復指令這些,怎麼修改??求大神!急急急
直接socket編程呗,知道端口和ip直接發送數據流就行吧
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Client
{
class Program
{
static void Main(string[] args)
{
try
{
int port = 2000;
string host = "127.0.0.1";
///創建終結點EndPoint
IPAddress ip = IPAddress.Parse(host);
//IPAddress ipp = new IPAddress("127.0.0.1");
IPEndPoint ipe = new IPEndPoint(ip, port);//把ip和端口轉化為IPEndpoint實例
///創建socket並連接到服務器
Socket c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);//創建Socket
Console.WriteLine("Conneting…");
c.Connect(ipe);//連接到服務器
///向服務器發送信息
string sendStr = "hello!This is a socket test";
byte[] bs = Encoding.ASCII.GetBytes(sendStr);//把字符串編碼為字節
Console.WriteLine("Send Message");
c.Send(bs, bs.Length, 0);//發送信息
///接受從服務器返回的信息
string recvStr = "";
byte[] recvBytes = new byte[1024];
int bytes;
bytes = c.Receive(recvBytes, recvBytes.Length, 0);//從服務器端接受返回信息
recvStr += Encoding.ASCII.GetString(recvBytes, 0, bytes);
Console.WriteLine("client get message:{0}", recvStr);//顯示服務器返回信息
///一定記著用完socket後要關閉
c.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("argumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException:{0}", e);
}
Console.WriteLine("Press Enter to Exit");
}
}
}