Changeset 464
- Timestamp:
- May 19, 2014, 12:27:14 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Network/CoolWeb/Network/UTCPServer.pas
r311 r464 67 67 end; 68 68 69 { TTCPServer } 70 71 TTCPClient = class 72 private 73 FActive: Boolean; 74 FSocket: TTCPBlockSocket; 75 procedure SetActive(AValue: Boolean); 76 public 77 Address: string; 78 Port: Word; 79 constructor Create; 80 destructor Destroy; override; 81 property Socket: TTCPBlockSocket read FSocket; 82 property Active: Boolean read FActive write SetActive; 83 end; 84 69 85 implementation 86 87 { TTCPClient } 88 89 procedure TTCPClient.SetActive(AValue: Boolean); 90 begin 91 if AValue and not FActive then begin 92 with FSocket do begin 93 CreateSocket; 94 Connect(Address, IntToStr(Port)); 95 if LastError <> 0 then raise Exception.Create('Socket connect error'); 96 end; 97 end else 98 if not AValue and FActive then begin 99 with FSocket do begin 100 CloseSocket; 101 end; 102 end; 103 FActive := AValue; 104 end; 105 106 constructor TTCPClient.Create; 107 begin 108 FSocket := TTCPBlockSocket.Create; 109 Address := '0.0.0.0'; 110 Port := 80; 111 end; 112 113 destructor TTCPClient.Destroy; 114 begin 115 Active := False; 116 FSocket.Free; 117 inherited Destroy; 118 end; 70 119 71 120 { TTCPServer }
Note:
See TracChangeset
for help on using the changeset viewer.