Article View: borland.public.cppbuilder.internet.socket
Article #4967Client gives 10049 instead of 10061
From: Hans-Jochen Trost
Date: Mon, 22 Nov 2004 23:12
Date: Mon, 22 Nov 2004 23:12
111 lines
4849 bytes
4849 bytes
All,
I am trying to set up a client-server system with the TServerSocket
and TClientSocket components. (BCB5, programs to run on Win2k and
Win98, machines side by side on a Windows 2000 LAN - my Win2k machine
is NOT the LAN server.) I thought I had followed the chat example
quite literally but when I try to connect my client to a server, I get
an error 10049 where the chat example as a client either succeeds
(server program is running and listening) or gives me a 10061 (server
program is not running). I'm making a mistake somewhere, and it
should be in the following code, but I simply cannot tell where.
The work-around would be to literally cut down the chat program and
then build up what I need it to do, and I've done the cut-down for a
client version successfully. However, if I don't understand why that
is working and this is not, I'll be running into traps in the future
time and again.
So here it comes, content of the include file first, the main form
file next (below the long bar //-------). There are one static
control, two buttons ("connect" to start talking to the server program
and "close" for program exit) and the client socket component on the
form.
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ScktComp.hpp>
class TForm1 : public TForm
{
__published: // IDE-managed Components
TClientSocket *ClientSocket1;
TLabel *Label2;
TButton *Button1;
TButton *Button2;
void __fastcall ClientSocket1Connect(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
private: // User declarations
String Server ;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include "JetControlClientForm.h"
// #pragma package(smart_init)
#pragma link "ScktComp"
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
TCustomWinSocket *Socket)
{
MessageBox(NULL, "OnConnect is fired.\n", "Jet Control Client",
MB_OK) ;
Label2->Caption = Socket->RemoteHost ;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (InputQuery("Computer to connect to:", "Address Name:", Server))
{
if (Server.Length() > 0) {
ClientSocket1->Host = Server ;
ClientSocket1->Active = true ;
}
}
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ClientSocket1->Close() ;
Close() ;
}
The program will get through the OnLookup and OnConnecting events and
then suffer the 10049 error ("Asynchronous socket error 10049"). My
immediat eobjective is to make this program give error 10061 instead.
I just don't see where I am missing something or got something wrong
that is done right in the chat example. Also, I apologize if there
have been discussions of this error before; I tried to find a
searchable archive of this newsgroup and failed. Among the most
recent about 1000 messages, there was a bare-bones examply by Remy way
back in June, but I don't see anything there either that would be
significantly different in terms of the socket calls.
I'd appreciate any advice.
Cheers, Jochen
hjtrost at microfab dot com
Nil nimium studeo, Caesar, tibi velle placere,
nec scire ut an sis albus an ater homo.
Catullus
Technical Details
Message-ID:
<eis4q01h3c6sgrfm7hfs0m0mj0bfkjf43o@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,42155a35e8f17c43,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: Hans-Jochen Trost <dont-email@but.post-re.ply> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Client gives 10049 instead of 10061 Date: Mon, 22 Nov 2004 17:12:53 -0600 Organization: MicroFab Technologies, Inc. Reply-To: dont-email@but.post-re.ply Message-ID: <eis4q01h3c6sgrfm7hfs0m0mj0bfkjf43o@4ax.com> X-Newsreader: Forte Free Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 66.14.146.145 X-Trace: newsgroups.borland.com 1101165176 66.14.146.145 (22 Nov 2004 15:12:56 -0700) Lines: 111 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail