HI guys
I am need to connect my pc with the PLC on the Ethernet Connection and I don't know about socket programing,
I have very search for this work and find any code in this site and usage then.
but have a some problem.
this is my usage code:
private void timer1_Tick(object sender, EventArgs e)
{
IPAddress ipAd = IPAddress.Parse("192.168.0.1");
TcpListener newList = new TcpListener(ipAd, 2000);
newList.Start();///// *****
Socket s = newList.AcceptSocket();
byte[] b = new byte[100];
int k = s.Receive(b);
textBox1.Text = k.ToString();
ASCIIEncoding asen = new ASCIIEncoding();
s.Send(asen.GetBytes(textBox1.Text));
s.Close();
}
I don't know this code is right, pls tell me that code is true or not?
and when run this code show this error as *** line:
" The requested address is not valid in its context"
detaile of this connection:
Pc IP: 192.168.0.2
PLC IP: 192.168.0.1
Port: 2000
Pls help me
tnx