Write some pairs of Point Pass file programs with Delphi (2)

zhaozj2021-02-17  62

Write some pairs of Point Pass file programs with Delphi (2)

END;

END;

CS.ONREAD (SENDER: TOBJECT; SOCKET: TCUSTOMWINSOCKET);

VAR

STEMP: STRING;

BUFSEND: POINTER;

Begin

SRECV: = Socket.ReceiveText;

Case SRECV [1] of

MP_REFUSE: SHOWMESSAGE ('Faint, Be Refused!');

MP_ACCEPT: Begin

Fssend: = TfileStream.create (OpenDialog1.FileName, FMopen);

// ibytepersend is a constant, and the size of the package is sent.

Socket.sendtext (MP_FILEPROPERTY TRUNC (fssend.size / ibytepersend) 1);

END;

MP_NEXTWILLBEDATA: Begin

Socket.sendtext (MP_NEXTWILLBEDATA);

END;

MP_DATA: Begin

Try

GetMem (Bufsend, IbytePersend 1);

IF (fssend.position 1 ibytepersend)

Begin

fssend.read (bufsend ^, ibytepersend);

Socket.sendbuf (bufsend ^, ibytepersend);

Fssend.free;

End // Ordinary transmission, size is ibytepersnd

Else Begin

Fssend.read (bufsend ^, fssend.size-fssend.position-1);

Socket.sendbuf (bufsend ^, fssend.size-fssend.position-1);

End; // last send, send the remaining data

Finally

FreeMem (Bufsend, IbytePersend 1);

End; {of try}

END;

MP_ABORT: Begin

// is canceled :(

Fssend.free;

END;

End; {of case}

END;

Standard:

Join the error judgment, optimize the program, join the Server and Client together, join the remaining time schedule display, make a multi-purpose file, join the chat function, become a good point to the program.

转载请注明原文地址:https://www.9cbs.com/read-30750.html

New Post(0)