unit dClientSock;
interface
uses ScktComp, Windows, Sysutils;
type
TCLSocket =
class
tClientSck: TClientSocket;
procedure ConnectClient(lpHost:
String; iPort: Integer);
procedure Send(lpTextMsg:
String);
function ReturnValue:
String;
procedure SetValue(lpNewValue:
String);
function ReturnConnect:Boolean;
procedure tClientSckConnecting(Sender: TObject; Socket: TCustomWinSocket);
procedure tClientSckConnect(Sender: TObject; Socket: TCustomWinSocket);
procedure tClientSckDisconnect(Sender: TObject; Socket: TCustomWinSocket);
procedure tClientSckRead(Sender: TObject; Socket: TCustomWinSocket);
private
{ Privat }
public
{ Publik }
end;
implementation
var
gCurrentVal:
String;
bIsConnected: Boolean;
gCurrentHost:
String;
function TCLSocket.ReturnValue:
String;
begin
result := gCurrentVal;
end;
procedure TCLSocket.SetValue(lpNewValue:
String);
begin
gCurrentVal := '
';
end;
function TCLSocket.ReturnConnect:Boolean;
begin
result := bIsConnected;
end;
procedure TCLSocket.tClientSckConnecting(Sender: TObject; Socket: TCustomWinSocket);
begin
bIsConnected := false;
gCurrentVal := '
Connecting to ' + gCurrentHost;
end;
procedure TCLSocket.tClientSckConnect(Sender: TObject; Socket: TCustomWinSocket);
begin
bIsConnected := true;
gCurrentVal := '
Connected to ' + gCurrentHost;
end;
procedure TCLSocket.tClientSckDisconnect(Sender: TObject; Socket: TCustomWinSocket);
begin
bIsConnected := false;
gCurrentVal := '
Connection lost from ' + gCurrentHost;
end;
procedure TCLSocket.tClientSckRead(Sender: TObject; Socket: TCustomWinSocket);
var
gServerText:
String;
begin
gServerText := Socket.ReceiveText;
end;
procedure TCLSocket.ConnectClient(lpHost:
String; iPort: Integer);
begin
gCurrentHost := lpHost;
tClientSck.Port := iPort;
//Access Violation
//tClientSck.Host := lpHost;
//tClientSck.Active := true;
end;
procedure TCLSocket.Send(lpTextMsg:
String);
begin
tClientSck.Socket.SendText(lpTextMsg);
end;
end.