I am writing a DLL that will have two sockets managed by the same
thread. In the thread's Execute method I am calling the message pump
from one of the sockets.
My question: will this message pump also handle the messages of the
second socket?
For reference (and so others can check for errors), here is the thread's
constructor, destructor and Execute method:
//
----------------------------------------------------------------------------
constructor TTicketThrd.Create(IP: AnsiString; Handle: THandle; ID:
integer);
begin
myIP := IP;
fHandle := Handle;
fID := ID;
TcpSocket := TWSocket.Create(Nil);
with TcpSocket do
OnDataAvailable = TcpDataAvailable;
OnSessionClosed = TcpDisconnected;
OnSessionConnected = TcpConnected;
end;
UdpSocket := TWSocket.Create(Nil);
UdpSocket.OnDataAvailable := UdpDataAvailable;
FreeOnTerminate := TRUE;
inherited Create(false);
end;
destructor TTicketThrd.Destroy;
begin
FreeAndNil(TcpSocket);
FreeAndNil(UdpSocket);
end;
procedure TTicketThrd.Execute;
begin
with TcpSocket do
begin
ThreadDetach();
MultiThreaded := true;
ThreadAttach();
end;
with UdpSocket do
begin
ThreadDetach();
MultiThreaded := true;
ThreadAttach();
end;
Sleep(0);
TcpSocket.MessageLoop();
Sleep(0);
UdpSocket.ThreadDetach;
TcpSocket.ThreadDetach;
end;
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be