Hi All,
I have done a cbuilder translation of Mr. Mestdagh's SpocketSpy
program. But, I have a problem. When I run the program and try to
connect with a server, I get this immediate error:
An unknown response was received in response to a request for
information from the news server 'SocketSpyC++ Local TCP Proxy'
Under the details button of the error dialog, I get:
SocketSpyC++ Local TCP Proxy
Configuration:
Account: SocketSpyC++ Local TCP Proxy
Server: 127.0.0.1
Protocol: NNTP
Port: 119
Secure(SSL): 0
Code: 800ccca0
I don't have any idea what the problem is. First, while trying to
debug, I put a popup messagebox at the end of the
WSocketServerClientConnect procedure to take a look at a variable.
What I discovered was that messagebox being open allowed the program
to actually connect and go further before error. After that, I
replaced the messagebox with an Application-ProcessMessages() loop
as a test. I was amazed that after that, the program ran completely
and reliably--everytime. It works just great, but I haven't tried
more than 1 connection because of the ProcessMessages loop. Though
the loop has been helpful, I doubt it is the appropriate fix for this.
I'm wondering if this problem is somehow related to changes made to
cbuilder in the 2007 edition I'm using. I have already discovered and
fixed 2 other problems related to the 2007 upgrade.
I'm using Vista64. My source code is included below. I hope you'll
forgive me if I have included too much code. My program is 257 lines.
Please have a look.
Regards,
Richard Christman
https://www.quicksilvermail.net
socketwins.h:
//
---
#ifndef socketwinsH
#define socketwinsH
//
---
#include Classes.hpp
#include Controls.hpp
#include StdCtrls.hpp
#include Forms.hpp
#include OverbyteIcsWndControl.hpp
#include OverbyteIcsWSocket.hpp
#include OverbyteIcsWSocketS.hpp
#include ComCtrls.hpp
//
---
class TSocketWin : public TForm
{
__published:// IDE-managed Components
TRichEdit *TCPLog;
TStatusBar *StatusBar;
TEdit *RemoteAddr;
TLabel *Label3;
TEdit *RemotePort;
TLabel *Label2;
TEdit *LocalPort;
TLabel *Label1;
TButton *ListenBtn;
TWSocketServer *WSocketServer;
void __fastcall WSocketServerClientConnect(TObject *Sender,
TWSocketClient *Client, WORD Error);
void __fastcall WSocketServerClientDisconnect(TObject *Sender,
TWSocketClient *Client, WORD Error);
void __fastcall WSocketServerSessionClosed(TObject *Sender, WORD
Error);
void __fastcall ListenBtnClick(TObject *Sender);
private:// User declarations
void __fastcall BgException(TObject *Sender, Exception *E, bool
CanClose);
void __fastcall ClientDataAvailable(TObject *Sender, WORD Error);
void __fastcall RemoteSessionConnected(TObject *Sender, WORD Error);
void __fastcall RemoteDataAvailable(TObject *Sender, WORD Error);
void __fastcall RemoteSessionClosed(TObject *Sender, WORD Error);
void __fastcall RemoteDnsLookupDone(TObject *Sender, WORD Error);
public: // User declarations
bool cancel;
TStrings *log;
__fastcall TSocketWin(TComponent* Owner);
__fastcall virtual ~TSocketWin();
void __fastcall Log(AnsiString Msg);
};
class TClient : public TWSocketClient
{
public:
AnsiString rcvd;
TWSocket *remote;
__fastcall TClient(TComponent *Owner);
__fastcall virtual ~TClient();
};
//
---
extern PACKAGE TSocketWin *SocketWin;
//
---
#endif
socketwins.cpp:
//
---
#include vcl.h
#pragma hdrstop
#include socketwins.h
//
---
#pragma package(smart_init)
#pragma link OverbyteIcsWndControl
#pragma link OverbyteIcsWSocket
#pragma link OverbyteIcsWSocketS
#pragma resource *.dfm
TSocketWin *SocketWin;
const AnsiString lineend = \r\n;
const bool linemode = true;
//
---
__fastcall TSocketWin::TSocketWin(TComponent* Owner)
: TForm(Owner)
{
log = TCPLog-Lines;
}
//
---
__fastcall TSocketWin::~TSocketWin()
{
}
//
---
void __fastcall TSocketWin::ListenBtnClick(TObject *Sender)
{
if (ListenBtn-Tag == 0)
{
NNTPLog-Clear();
WSocketServer-Banner = Welcome to OverByte