tcpclient domain summary bottom category constantly being disposed
i have an summary bottom category tcpclient field:
public summary category controllerbase
{
middle stable tcpclient tcpclient;
it slight setup connection:
private vacant setupconnection(ipaddress ethernetaddress, ushort tcpport)
{
(this.tcpclient == zero || !this.tcpclient.connected)
{
this.tcpclient = new tcpclient();
try
{
this.tcpclient.connect(ethernetaddress, tcpport);
}
catch(exception ex)
{
pitch new timeoutexception("the device respond.\n" + ex.message);
}
}
}
and methods ask data:
middle stable practical byte[] requestdata(ipaddress ethernetaddress, ushort tcpport, byte[] data, bool ignoreresponse)
{
setupconnection(ethernetaddress, tcpport);
//the rest formula uses this.tcpclient
there few others, such requestrawdata, etc... mandatory unequivocally specific hardware communication protocols, nonetheless that's biased doubt any way.
i following have classes get category overrule bottom category methods:
public category controller : controllerbase
{
middle practical byte[] requestdata(byte[] data, bool ignoreresponse)
{
relapse base.requestdata(this.eth0.ethernetaddress, this.eth0.tcpport, data, ignoreresponse);
}
the formula works but any exceptions, nonetheless everytime setupconnection slight called,
the tcpclient instance (tcpclient) seems disposed, new combined bond slight called again, unequivocally negligence down communication process.
note: open methods child category requestdata method,
abstracting sum developer controlling library.
such setdevicepower(byte powerlevel), querydevicename() etc...
code such this:
controller controller = new controller("172.17.0.3",34000);
string name = controller.querydevicename();
controller.setdevicepower(200);
causes bond slight called twice... since being likely between calls?
Comments
Post a Comment