Since yesterday I've sticked at problem how to read the data from blocking socket connection, using thread. Can anyone help on this?
I'm writing server-application (SA) and client-application (CA) in C++ Builder 6 under Windows OS.
In CA I use TClientSocket's component ClientSocketSta t and in SA TServerSocket's component ServerSocketSta t to exchange data. If no data passed in 5 seconds I need to close the connection.
This is what I've done?
On ServerSocketSta t's event OnGetSocket I initialize and start cStatThread's thread object ( class cStatThread is derived from TServerClientTh read)
This is cStatThread's constructor:
This is cStatThread's ClientExecute method:
Where is the misstake?
How else can I read the data in thread from socket connection with time limit?
Any help or advises are appreciated.
I'm writing server-application (SA) and client-application (CA) in C++ Builder 6 under Windows OS.
In CA I use TClientSocket's component ClientSocketSta t and in SA TServerSocket's component ServerSocketSta t to exchange data. If no data passed in 5 seconds I need to close the connection.
This is what I've done?
On ServerSocketSta t's event OnGetSocket I initialize and start cStatThread's thread object ( class cStatThread is derived from TServerClientTh read)
Code:
void __fastcall TForm1::ServerSocketStatGetSocket(TObject *Sender,
int Socket, TServerClientWinSocket *&ClientSocket)
{
ClientSocketN=new TServerClientWinSocket(Socket,ServerSocketStat-> Socket;
cStatThread* sthr=new cStatThread(true,ClientSocket);
sthr->Resume();
}
Code:
__fastcall cStatThread::cStatThread(bool CreateSuspended, TServerClientWinSocket* aSocket)
: TServerClientThread(CreateSuspended,aSocket) {}
Code:
...............
TWinSocketStream* statStream;
try{statStream=new TWinSocketStream(ClientSocket,5000);}
//after this line I receive Exception Message "Socket must be in blocking mode". But either ServerStatSocket or ClientStatSocket are in blocking modes
(stThreadBlocking and ctBlocking)
.................
How else can I read the data in thread from socket connection with time limit?
Any help or advises are appreciated.