Kod: Tümünü seç
using System.Net.Sockets;
using System.Collections;
using System.Runtime.InteropServices;
public partial class Form1 : Form
{
public byte[] x1 = new byte[9];
public byte[] sendBytes;
public string space;
public byte[] bytes;
TcpClient tcpClient = new System.Net.Sockets.TcpClient();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string msg = "";
x1[0] = 0x02;
x1[1] = 0x00;
x1[2] = 0x00;
x1[3] = 0x00;
x1[4] = 0x00;
x1[5] = 0x00;
x1[6] = 0x00;
x1[7] = 0x01;
x1[8] = 9;
try
{
NetworkStream networkStream = tcpClient.GetStream();
sendBytes = null;
sendBytes = x1;
networkStream.Write(sendBytes, 0, sendBytes.Length);
space = new string(' ', tcpClient.ReceiveBufferSize);
bytes = Encoding.ASCII.GetBytes(space);
networkStream.Read(bytes, 0, tcpClient.ReceiveBufferSize);
}
catch
{
msg = "hata ...";
label1.Text = msg;
}
if (bytes[0] == 49)
{
msg = "başarılı...";
label1.Text = msg;
}
}
}
Kod: Tümünü seç
public
{ Public declarations }
x1:array[0..8] of byte;
end;
procedure TForm1.Button14Click(Sender: TObject);
begin
//TcpClient1.Connect;
x1[0] := $02;
x1[1] := $00;
x1[2] := $00;
x1[3] := $00;
x1[4] := $00;
x1[5] := $00;
x1[6] := $00;
x1[7] := $01;
x1[8] := 9;
// TcpClient1
end;