TServerClientThread problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanYAua007
    New Member
    • Oct 2007
    • 6

    TServerClientThread problem

    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)


    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();
    }
    This is cStatThread's constructor:

    Code:
    __fastcall cStatThread::cStatThread(bool CreateSuspended, TServerClientWinSocket* aSocket)
       : TServerClientThread(CreateSuspended,aSocket) {}
    This is cStatThread's ClientExecute method:

    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)
    .................
    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.
Working...