如何用winsock傳送中文 |
缺席
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
|
frankiech
中階會員 發表:7 回覆:78 積分:52 註冊:2002-08-29 發送簡訊給我 |
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
|
deity
尊榮會員 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
|
deity
尊榮會員 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
读取流,
引用KO前辈的回答:
//server部分
procedure TForm1.TCPServerExecute(AThread: TIdPeerThread);
var
SRequest: string;
begin
with AThread.Connection do
begin
AThread.Synchronize(IncrConnectionCount);
WriteLn('Welcome to Auto Update Server');
try
SRequest := UpperCase(ReadLn);
//傳送檔案
if SRequest = 'GETFILE' then //傳檔需求
begin
WriteLn('FILENAME?'); //尋問要取那一個檔
SRequest := UpperCase(ReadLn);
SendFile(AThread, SRequest);//這裡是將一個檔案變成Stream
end; finally
Disconnect;
AThread.Synchronize(DecrConnectionCount);
end;
end;
end; -------------------------------------------------------------------------------- 引言:
-------------------------------------------------------------------------------- //client部分
function TForm1.GetFiles(SaveFilePath: string; iFileName: Tstrings): boolean;
var
FStream: TFileStream;
i:integer;
SResponse: string;
begin
try
TCPClient.Connect();
while TCPClient.Connected do
begin
SResponse := UpperCase(TCPClient.ReadLn); //讀取伺服器回應
if Pos('WELCOME', SResponse) = 0 then
break; //若無回應則離開 TCPClient.WriteLn('GETFILE');
SResponse := UpperCase(TCPClient.ReadLn); //讀取伺服器回應
for i:=0 to iFileName.Count-1 do
begin
TCPClient.WriteLn(iFileName.Strings[i]);
try
FStream := TFileStream.Create(SaveFilePath '\' iFileName.Strings[i], fmCreate);
FStream.Seek(0, soFromBeginning);
TCPClient.ReadStream(FStream, -1, True);
finally
FStream.Free;
end;
end;
end;
finally
TCPClient.Disconnect;
end;
end; ——行径窄处,留一步与人行——
|
apple12
一般會員 發表:28 回覆:23 積分:10 註冊:2003-05-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |