¾èÔù | ¹ã¸æ | ×¢²á | ·¢²¼ | ÉÏ´« | ¹ØÓÚÎÒÃÇ    
  ÔÁICP±¸10103342ºÅ-1 DELPHIºÐ×Ó | ºÐ×ÓÎÄÕ | ºÐ×ÓÎÊ´ðÐüÉÍ | ×îиüР| ºÐ×Ó¼ìË÷ | ÏÂÔØÖÐÐÄ | ¸ß¼¶ËÑË÷    
  ¾«Æ·×¨Çø | ·±ówÖÐÎÄ | ½±Àø¹«¸æÀ¸ | ֱͨ³µÕ˺ŵǽ | ¹Ø±ÕGOOGLE¹ã¸æ | ÁÙʱÁôÑÔ    
 
¹ã¸æ
ÆÀÂÛ£ºScktIocp(ÓëScktComp¼æÈݵÄIOCP×é¼þ)
melice 42149 2012/2/25 22:09:00
ÏÂÔØÁ´½ÓËÆºõdownÁË£¬Ë­Äܹ²ÏíÒ»ÏÂô£¬Ð»Ð»¡£
from 38519 2009/9/1 17:05:43
ÎÒÊÇÕâÑù¸ÄµÄ

function ReceiveText: string; virtual;
function TCustomWinSocket.ReceiveText: string;
begin
  if ReceiveLength > 0 then
  begin
    SetLength(Result, ReceiveLength);
    ReceiveBuf(Result[1], Length(Result));
  end else Result := '';
end;

function TServerClientWinSocket.ReceiveLength: Integer;
begin
  Result := FStream.Position;
end;
function TServerClientWinSocket.ReceiveBuf(var Buf; Count: Integer): Integer;
var
  P, Len: Integer;
begin
  Lock;
  try
    if FStream.Position >= Count then begin
      P := FStream.Position - Count;
      FStream.Position := P;
      Len := Count;
    end else begin
      P := 0;
      Len := FStream.Position;
      FStream.Position := P;
    end;

    Result := FStream.Read(Buf, Len);
    if FStream.Position = FStream.Size then begin
       //´óÓÚ4K¾Í·ÅµôÖØÐ·ÖÅäÄÚ´æ,·ñÔò,Ö»Êǽ«Ö¸ÕëÒÆ¶¯µ½Í·²¿
      if FStream.Size > 4096 then
        FStream.Clear
      else
        FStream.Position := 0;
    end else begin
      FStream.Position := P + (Len - Result);
    end;
  finally
    UnLock;
  end;
end;
cmd9x 38066 2009/7/19 11:25:48
ÐÂÐ޸ģº
TCustomWinSocketÀàÌí¼ÓÁË
function ReceiveText: string; virtual;
function TCustomWinSocket.ReceiveText: string;
begin
  if ReceiveLength > 0 then
  begin
    SetLength(Result, ReceiveLength);
    ReceiveBuf(Result[1], Length(Result));
  end else Result := '';
end;

function TServerClientWinSocket.ReceiveLength: Integer;
begin
  Result := FStream.Position;
end;
function TServerClientWinSocket.ReceiveBuf(var Buf; Count: Integer): Integer;
var P1: Integer;
  PS, PD: Pointer;
begin
  Lock;
  try
    P1 := FStream.Position;
    FStream.Seek(0, soBeginning);
    FStream.ReadBuffer(Buf, Count);
    if FStream.Position = P1 then
    begin
    {´óÓÚ4K¾Í·ÅµôÖØÐ·ÖÅäÄÚ´æ,·ñÔò,Ö»Êǽ«Ö¸ÕëÒÆ¶¯µ½Í·²¿}
      if FStream.Size > 4096 then
        FStream.Clear
      else
        FStream.Seek(0, soBeginning);
    end
    else if FStream.Position < P1 then
    begin
      PS := Pointer(Longint(FStream.Memory) + FStream.Position);
      Move(PS^, FStream.Memory^, P1 - FStream.Position);
      FStream.Position := P1 - FStream.Position;
    end;
  finally
    UnLock;
  end;
end;

QQȺ£º1285183
glwang 37960 2009/7/13 15:04:09
лл¿ØÖ÷µÄ½â´ð£¬Ï£ÍûÄܳÖÐøÍêÉÆÉý¼¶£¡
cmd9x 37957 2009/7/13 12:36:48
£±¡¢Ö§³ÖD2009ûʲôÄѵ쬰ÑËùÓеÄString¸Ä³ÉAnsiString£¬PChar¸Ä³ÉPAnsiPChar¾Í²î²»¶àÁË¡£
£²¡¢Õâ¸ö×é¼þÊÇÒ»¸ö·þÎñ×é¼þ£¬ÉèIPµØÖ·×öÊ²Ã´ÄØ£¿
£³¡¢ÖÁÓÚÖ»ÄÜÁ¬ÉÙÁ¿Á´½ÓµÄÇé¿öµ¹ÊÇûÓÐÅöµ½£¬Äã¿ÉÒÔ×Ô¼ºÐ´¸ö¿ÉÒÔ²úÉú¶à¸ö¿Í»§¶ËµÄ³ÌÐòÀ´²â£¬ÒªÏëÁ´½ÓÉÏÍò£¬±ØÐëµ¼Èë×¢²áÎļþÒÔÐÞ¸ÄϵͳÁ´½ÓÊýÏÞÖÆ
£´¡¢¹ØÓÚÄÚ´æÐ¹Â©Õâ¸öÎÒûʲôºÃ˵µÄ£¬Ô´Âë°Ú×ÅÄØ£¬¸ßÊÖÃǰïæ¼ì²éһϰÉ
£µ¡¢¹ØÓÚÌæ»»ScktComp£¬ÎҵĽ¨ÒéÊÇÔÚµ¥ÔªÒýÈëʱ¼Ó±àÒëÑ¡Ïî{$IFDEF IOCP}uScktIocp{$ELSE}uScktComp{$ENDIF};ÕâÑù¾Í¿ÉÒÔÖ±½ÓÌæ»»ÁË
cmd9x 37956 2009/7/13 12:23:59
¹ØÓÚÄÚ´æÁ÷½ÓÊÕÊý¾Ý£¬Éè¼Æ³õÖÔÊÇÕâÑùµÄ£º
ÓÃÄÚ´æÁ÷½ÓÊÕÊý¾Ýºó»á´¥·¢OnReadʼþ£¬ÊµÏÖÕâ¸öʼþʱҪµ÷ÓÃ
TServerClientWinSocket.ReceiveBuf
Õâʱ»á½«Êý¾Ý´ÓÄÚ´æÁ÷ÖжÁ³öÀ´£¬ÎªÁ˲»Æµ·±·ÖÅäÄڴ棬ֻ¶ÔÄÚ´æÁ÷µÄÖ¸Õë¸ÄÁËλÖá£
¶øÕæÕýÓ¦¸Ã¸ÄµÄµØ·½ÊÇ
function TServerClientWinSocket.ReceiveLength: Integer;
begin
  Result := FStream.Position;
  {Ô­À´ÊÇResult := FStream.Size;(µÄÈ·»áÒòΪÉÏ´ÎÊý¾Ý½Ï¶à¶ø²úÉúÀ¬»øÊý¾Ý)}
end;
netfun2000 37676 2009/6/7 15:57:34
FastMM4·¢ÏÖÄÚ´æÐ¹Â©£º
----------2009/6/7 15:52:36----------
FastMM has detected an error during a free block scan operation. FastMM detected that a block has been modified after being freed. 

The previous block size was: 4127

This block was previously allocated by thread 0xF84, and the stack trace (return addresses) at the time was:
402D48 
456CA4 
4583CA 
44D09F 
45475C 
4586A4 
7C82F23B [Unknown function at ProcessIdToSessionId]

The allocation number was: 527

The block was previously freed by thread 0xF84, and the stack trace (return addresses) at the time was:
402D73 

The current thread ID is 0xF84, and the stack trace (return addresses) leading to this error is:
40B826 
40B86E 
4041FF 
4044BE 
7C82F23B [Unknown function at ProcessIdToSessionId]

Current memory dump of 256 bytes starting at pointer address 7FF33110:
41 02 00 C0 00 00 00 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
A  .  .  ? .  .  .  .  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
€  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €  €
dozhyuy 37660 2009/6/5 15:58:44
ºÃ¶«Î÷....ѧϰÁË
yao_ming 37585 2009/5/26 19:45:56
ÄãºÃ£¬ÎÒÏÂÁËÄãµÄ¶«Î÷£¬ÓÃÄãµÄ±àÒë³ÌÐò²âÊÔ£¬×î¶àÖ»ÄÜ´ïµ½278¸öÁ¬½Ó£¿ÇëÊÍÒÉ£¬Ð»Ð»¡£
peliao 37567 2009/5/25 11:47:55
ÔÙ¹ýÒ»Äê,ÎÒ¿´ÎÒÄܰÑÎÒдµÄIOCP·¢³öÀ´²», ¶ÔÁË,ÎÒµÄÒ²ºÍÂ¥Ö÷Ô´×Ôͬһ×÷Õß
glwang 37565 2009/5/25 7:28:50
תÌûzhousanÐÞÕýµÄÌû×Ó
//zhousan ÐÞÕýÒ»¸öbug 
//½ÓÊÕµ½Êý¾ÝÖ±½ÓÔÚÉÏ´ÎÊý¾Ý»ù´¡Éϸ²¸Ç£¬ÈôÉÏ´ÎÊý¾Ý½Ï¶à£¬Ôò»á¶à³öÒ»¶ÎÀ¬»øÊý¾Ý
//µ¥Ôª£ºScktIocp.pas

function TServerClientWinSocket.WorkBlock(var Block: PBlock;
  Transfered: DWORD): DWORD;
var
  ErrCode: Integer;
  Flag, BytesSend: Cardinal;
begin
  Result := RESPONSE_SUCCESS;
  with Block^.Data do
  try
    case Block^.Data.Event of
      seRead:
      begin
        {ÀûÓÃÄÚ´æÁ÷À´±£´æÊÕµ½µÄÊý¾Ý,ÓпÉÄÜÔì³ÉƵ·±µÄÄÚ´æÖØÐ·ÖÅä,¿ÉÒԸĽø}
        Lock;
        FStream.Clear;         //<<---½ÓÊÕµ½Á÷ǰÏÈÇå¿ÕÔ­ÄÚÈÝ£¬
        FStream.Write(Buffer, Transfered);
        UnLock;
        Self.Event(Self, seRead);        
        if not PrepareRecv(Block) then
          Result := RESPONSE_FAIL;
      end;
      seWrite:
      begin
//        Self.Event(Self, seWrite);
        Dec(wsaBuffer.len, Transfered);
        if wsaBuffer.len <= 0 then
        begin
          { ·¢ËÍÍê³É£¬½«BlockÖÿգ¬·µ»Øµ½FBlockµÄ¿ÉʹÓõĻºÇøÖР}
          Block.Data.IsUse := False;
          Block := nil;
        end else
        begin
          { Êý¾Ý»¹Ã»·¢ËÍÍê³É£¬¼ÌÐø·¢ËÍ }
          Flag := 0;
          Inc(wsaBuffer.buf, Transfered);
          FillChar(Overlapped, SizeOf(Overlapped), 0);
          if SOCKET_ERROR = WSASend(FSocket, @wsaBuffer, 1, BytesSend,
          Flag, @Overlapped, nil) then
          begin
          ErrCode := WSAGetLastError;
          if ErrCode <> ERROR_IO_PENDING then
          Error(Self, eeSend, ErrCode);
          end;
        end;
      end;
    end;
  except
    Result := RESPONSE_FAIL;
  end;
end;
glwang 37535 2009/5/21 18:33:34
²»ÄÜÉèÖÃIOCP×é¼þµÄIPµØÖ·£¬ÓÐëÓ𡣡£¡£¡£¡£¡£¡£¡£¡£¡£¡
blueflag 37528 2009/5/20 23:06:09
²»´í£¬Ï£Íû¼ÌÐø¸üÐÂ~~~~~~~~~~
array 37510 2009/5/19 8:56:29
Èç¹ûÄÜ×öµ½¸úTServerSocketÍêÈ«¼æÈݾÍÍêÃÀÁË¡£ÏÖÔڵİ汾¸úTServerSocketʹÓÃÉÏÊDz¶à£¬»¹²»ÄÜ×öµ½Ö±½ÓÌæ»»¾ÍÄÜÓµÓÐIOCPÌØÐÔ¡£
softbug 37509 2009/5/18 23:12:27
Ö§³Ö2009ÁËÂð£¿
555a 37504 2009/5/18 14:00:41
×î½üÏëѧÕâ·½ÃæµÄ¶«¶«,Ì«ºÃÁË,лл..........
siow 37503 2009/5/18 13:00:30
ºÃ¶«¶«£¬Ñ§Ï°ing
µÚÒ»Ò³ ÉÏÒ»Ò³ ÏÂÒ»Ò³ ×îºóÒ³ ÓÐ 17 Ìõ¼Í¼ ¹²1Ò³ 1 - 17
 Óû§Ãû£º
 ÃÜ¡¡Â룺
×Ô¶¯µÇ½(30ÌìÓÐЧ)
 
  DELPHIºÐ×Ó°æÈ¨ËùÓÐ ¼¼ÊõÖ§³Ö:ÉîÛÚÊÐ÷ëÈð¿Æ¼¼ÓÐÏÞ¹«Ë¾ 1999-2024 V4.01 ÔÁICP±¸10103342ºÅ-1 ¸üÐÂRSSÁбí