⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitacceptthread.~pas

📁 1
💻 ~PAS
字号:
unit UnitAcceptThread;

interface

uses
  Classes,WinSock,WIndows,SysUtils;

type
  AcceptThread = class(TThread)
  private
    { Private declarations }
  protected
    asock:TSocket;
    addr:TSockAddr;
    procedure Execute; override;
  public
    procedure SetPar(s:TSocket;a:TSockAddr);
  end;

implementation
uses
UnitMain;
{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure AcceptThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ AcceptThread }

procedure AcceptThread.Execute;
var
Buf:array[0..1023] of char;
p:pDataBuf;
a:Word;
b:integer;
begin
   recv(asock,Buf,sizeof(Buf),0);
   if (pHeadData=nil) then
      begin
      GetMem(pHeadData,sizeof(DataBuf));
      pHeadData.buf:=string(Buf);
      pHeadData.Next:=nil;
      pRearData:=pRearData;
      end
      else
         begin
         GetMem(pRearData.Next,sizeof(DataBuf));
         pRearData:=pRearData.Next;
         pRearData.buf:=string(Buf);
         pRearData.Next:=nil;
         end;
   SendMessage(MainForm.Handle,WM_GETFROMREMOTE,addr.sin_addr.S_addr,1);
   CloseSocket(asock);
  { Place thread code here }
end;

procedure AcceptThread.SetPar(s:TSocket;a:TSockAddr);
begin
asock:=s;
addr:=a;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -