Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCustomWinSocket

Status
Not open for further replies.

Jalr2003

Technical User
May 15, 2003
26
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top