Hi,
I was wondering where I could find good help on how to use TCustomWinSocket.
I am trying to write an application that sends commands to a device using its Ethernet Port as well as its serial port.
I created a base clase with pure virtual functions that includes four functions for communicating with the device, they are: open, close, write, and read.
It looks something like this:
class TDevice {
public:
virtual void __fastcall Open() = 0;
virtual void __fastcall Close() = 0;
virtual int __fastcall Read(AnsiString& Response) = 0;
virtual int __fastcall Write(const AnsiString& Cmd) = 0;
virtual dstring __fastcall Command1 = 0;
};
class TSerial: virtual public TDevice {
public:
TSerial() { CommMode = RS232; }
void __fastcall Open();
void __fastcall Close();
int __fastcall Read(AnsiString& Response);
int __fastcall Write(const AnsiString& Command);
TWinPort SerialPort;
};
class TEthernet: virtual public TDevice
{
public:
TEthernet() { CommMode = ETHERNET; }
void __fastcall Open();
void __fastcall Close();
int __fastcall Read(AnsiString& Response);
int __fastcall Write(const AnsiString& Command);
TCustomWinSocket* Socket;
};
The serial communication is implemented, and works fine, and now I want to use TCustomWinSocket to create the open, close, write, and read functions to overwrite the ones from TDevice.
I am not very familiar with sockets, so I was wondering if someone could give me some directions.
Thanks,
Jalr2003
I was wondering where I could find good help on how to use TCustomWinSocket.
I am trying to write an application that sends commands to a device using its Ethernet Port as well as its serial port.
I created a base clase with pure virtual functions that includes four functions for communicating with the device, they are: open, close, write, and read.
It looks something like this:
class TDevice {
public:
virtual void __fastcall Open() = 0;
virtual void __fastcall Close() = 0;
virtual int __fastcall Read(AnsiString& Response) = 0;
virtual int __fastcall Write(const AnsiString& Cmd) = 0;
virtual dstring __fastcall Command1 = 0;
};
class TSerial: virtual public TDevice {
public:
TSerial() { CommMode = RS232; }
void __fastcall Open();
void __fastcall Close();
int __fastcall Read(AnsiString& Response);
int __fastcall Write(const AnsiString& Command);
TWinPort SerialPort;
};
class TEthernet: virtual public TDevice
{
public:
TEthernet() { CommMode = ETHERNET; }
void __fastcall Open();
void __fastcall Close();
int __fastcall Read(AnsiString& Response);
int __fastcall Write(const AnsiString& Command);
TCustomWinSocket* Socket;
};
The serial communication is implemented, and works fine, and now I want to use TCustomWinSocket to create the open, close, write, and read functions to overwrite the ones from TDevice.
I am not very familiar with sockets, so I was wondering if someone could give me some directions.
Thanks,
Jalr2003