Newsgroup: it.comp.lang.delphi
Titolo: Problematica con Thread con componenti TServerSocket

Salve ragazzi sto realizzando un server con la componente
TServerSocket, dato che questo server deve accettare la connessione su
due porte diverse untilizzo due di questi componeti.
Ho aggiunto un Thread affinche quando il server riceve dati da una
porta li dirotta sull altra e viceversa...ma sulla procedura OnExcute
nn appena inserisco qualche riga di codice che riguarda il socket mi da
un errore, del tipo: Socket nn connesso eindirizzo nn fornito durante
l'avvio su un socket di datagramma che utlizza la chiamata sendto.
Richiesta di invio o ricezione annullata(10057),on API recv.
Il codice è il seguente
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
  Dialogs, ScktComp, StdCtrls;
type
TServerThread = class(TThread)
private
FMainFormHandle: HWND;
Server1:  TServerSocket;
Server2:  TServerSocket;
private
procedure Execute; override;
public
constructor Create; reintroduce; virtual;
//destructor Destroy; override;
procedure Open(AMainFormHandle: HWND; A1Port:Integer; A2Port:Integer;
AResume: Boolean); virtual;
end;
type
  TForm1 = class(TForm)
    tcpServer: TServerSocket;
    edLocalAddress: TEdit;
    lblLocalAddress: TLabel;
    ListBox1: TListBox;
    Edit: TEdit;
    ActiveBtn: TButton;
    DeactiveBtn: TButton;
    tcpServer2: TServerSocket;
    procedure FormCreate(Sender: TObject);
    procedure ActiveBtnClick(Sender: TObject);
    procedure DeactiveBtnClick(Sender: TObject);
  procedure WMStartReceivedData(var Msg: TMessage); message
WM_USER+100;
  private
    { Private declarations }
     FServerThread: TServerThread;
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
uses
  WinSock;
{ Helper Functions }
function DNSLookup(const HostName: String): String;
var
  IP: TInAddr;
  HostEntry: PHostEnt;
begin
  Result := HostName;
  HostEntry := gethostbyname(PChar(HostName));
  if (HostEntry <> nil) and (HostEntry.h_addrtype = AF_INET) then
  begin
    IP := PInAddr(HostEntry^.h_addr^)^;
    Result := inet_ntoa(IP);
  end;
end;
function ReverseDNSLookup(const IPAddress: String): String;
var
  IP: TInAddr;
  HostEntry: PHostEnt;
begin
  Result := IPAddress;
  IP := TInAddr(inet_addr(PChar(IPAddress)));
  if Integer(IP.S_addr) <> Integer(INADDR_NONE) then
  begin
    HostEntry := gethostbyaddr(@IP, 4, AF_INET);
    if HostEntry <> nil then
      Result := HostEntry^.h_name;
  end;
end;
function FormatAddress(const HostName: String; const IPAddress:
String): String;
var
  Name, IP: String;
begin
  if IPAddress = '' then
    IP := DNSLookup(HostName)
  else
    IP := IPAddress;
  if HostName = '' then
    Name := ReverseDNSLookup(IP)
  else
    Name :=  HostName;
  if Name <> IP then
    Result := Format('%s (%s)', [Name, IP])
  else
    Result := Name;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FServerThread:= TServerThread.Create;
ActiveBtn.Visible:= true;
DeactiveBtn.Visible:= false;
edLocalAddress.Text := FormatAddress('', '');
//tcpServer.Port:= 8090;
//tcpServer2.Port:= 8091;
if tcpServer.Active and tcpServer2.Active then
Edit.Text:= 'Server is running' else
Edit.Text:= 'Server is not running';
end;
procedure TForm1.ActiveBtnClick(Sender: TObject);
begin
FServerThread.Open(Self.Handle,8090,8091,true);
//tcpServer.Active:= True;
//tcpServer2.Active:= True;
Edit.Text:= 'Server is running';
ActiveBtn.Visible:= False;
DeactiveBtn.Visible:= True;
end;
procedure TForm1.DeactiveBtnClick(Sender: TObject);
begin
tcpServer.Active:= false;
tcpServer2.Active:= false;
ActiveBtn.Visible:= True;
DeactiveBtn.Visible:= False;
Edit.Text:= 'Server is not running';
end;
procedure TForm1.WMStartReceivedData(var Msg: TMessage);
begin
ListBox1.Items.Add('arrivato');
end;
{ TClientThread }
procedure TServerThread.Execute;
var
line: String;
N: Cardinal;
begin
if Server1.Socket.LocalPort = 8090 then
Server1.Socket.ReceiveText;
PostMessage(FMainFormHandle,WM_USER+100, N, 0)
end;
constructor TServerThread.Create;
begin
   inherited Create(True);
end;
procedure TServerThread.Open;
begin
FMainFormHandle := AMainFormHandle;
Server1 := TServerSocket.Create(nil);
Server2 := TServerSocket.Create(nil);
Server1.Port:=A1Port;
Server2.Port:=A2Port;
Server1.Active:=True;
server2.Active:=True;
if AResume then Resume;
end;
end.
Qualcuno mi puo aiutare?

quello è un errore socket.
Hai gia visto su msdn il significato del codici di errore restituiti da 
winsock?
AS