T
takdick
Unregistered / Unconfirmed
GUEST, unregistred user!
我的傳送文件程序有點問題,在自己的機子上測試時一切正常,但把server端放在另一機子上運行時,client端可接收文件,文件大小也正確,但卻無法執行,提示'c:/test.exe僅完成部分的readprocessmemory或writeprocessmemory要求.',請問如何解決?謝謝.
主要代碼如下:
client端:
rcv := Socket.ReceiveText;
left := filesize - count;
if AnsiPos('go~',rcv)=1 then
begin
if sizeof(buf2)<left then
begin
ms2.Read(buf2,sizeof(buf2));
Socket.SendBuf(buf2,sizeof(buf2));
count := count + sizeof(buf2);
end
else
begin
ms2.Read(buf2,left);
Socket.SendBuf(buf2,left);
ms2.Free;
end;
server端:
len:=socket.ReceiveLength;
if len<8 then
begin
rcv:=socket.ReceiveText;
filesize:=strtoint(rcv);
count:=0;
socket.SendText('go~');
end
else
begin
left:=filesize-count;
if sizeof(buf2)<left then
begin
socket.ReceiveBuf(buf2,sizeof(buf2));
fs.Write(buf2,sizeof(buf2));
count:=count+sizeof(buf2);
socket.SendText('go~');
end
else
begin
socket.ReceiveBuf(buf2,left);
fs.Write(buf2,left);
fs.free;
socket.Close;
end;
end;
主要代碼如下:
client端:
rcv := Socket.ReceiveText;
left := filesize - count;
if AnsiPos('go~',rcv)=1 then
begin
if sizeof(buf2)<left then
begin
ms2.Read(buf2,sizeof(buf2));
Socket.SendBuf(buf2,sizeof(buf2));
count := count + sizeof(buf2);
end
else
begin
ms2.Read(buf2,left);
Socket.SendBuf(buf2,left);
ms2.Free;
end;
server端:
len:=socket.ReceiveLength;
if len<8 then
begin
rcv:=socket.ReceiveText;
filesize:=strtoint(rcv);
count:=0;
socket.SendText('go~');
end
else
begin
left:=filesize-count;
if sizeof(buf2)<left then
begin
socket.ReceiveBuf(buf2,sizeof(buf2));
fs.Write(buf2,sizeof(buf2));
count:=count+sizeof(buf2);
socket.SendText('go~');
end
else
begin
socket.ReceiveBuf(buf2,left);
fs.Write(buf2,left);
fs.free;
socket.Close;
end;
end;