Need to connect to internet on Win 98SE (get 10049 on connect)

Posted on 2006-07-18
Last Modified: 2013-11-17
I'm having trouble getting a BCB 6.0 TClientSocket to connect to the internet on a Windows 98SE machine.

I've written the code (on a Windows XP computer) to transmit user registration information to my website.  It uses a TClientSocket to connect to, and then uses a TWinSocketStream to transmit the information and receive a reply.  On the Windows XP computers, this works fine.  On the Windows 98SE computer, I get a messagebox saying "Windows socket error (10049) on API 'connect.' "  Other people have had similar problems, but the answers on EE and the Usenet have not been helpful.

Here's what I've found:

On the Windows 98SE computer, the error is occurring during or after the TClientSocket's OnConnecting event (when it *supposedly* has looked up the address of the server and before it actually establishes the connection) and before the OnConnect event  (It never enters the developer-defined OnConnect function.)  It does not trigger the OnError event.  The error occurs whether I try to specify the site by setting the Host or the Address property of the TClientSocket.

On the Windows XP computer, I've discovered that:
When I specify the server by setting the Host property of the TClientSocket, the Address property remains blank throughout the connection and transmission.  This is interesting because the BCB help says that the OnConnecting event "is the first opportunity to obtain the actual port and IP address of the server endpoint of the connection that is about to form," implying that Address *should* be set sometime during lookup, so that you can read it.  Also, when I connect by setting Address and clearing Host, the TClientSocket connects to a DNS server anyway.  (Correct me if I'm wrong, but I thought that DNS servers existed to find the IP address associated with a domain name.  If the TClientSocket has an IP address and *no domain name*, why is it connecting to a DNS?)

My main $100 question is, is there any reliable solution that will let me connect to the internet and stream information to and from a website on both Windows 98SE and Windows XP?  (And presumably everything in between.)  The solution could include (preferably free) third-party packages or implementing multiple methods for different operating systems.  Or requiring that certain (preferably official Microsoft) free software be installed on the user's computer.
Question by:MadDavid
  • 3
  • 2
LVL 14

Expert Comment

ID: 17133953
Can you reproduce this problem using a small test program, doing for example a query on google?
If you can post such a program, it would make it for us a bit easier, and guarantees for example it is not related to your website;

If the example is a bit longer, you can post it on (
LVL 16

Expert Comment

by:George Tokas
ID: 17139769
This behavor is strange...
I personaly using TServer/TClient sockets for more than 4 years now and didn't had something like that...
Can you post how you are assigning the host and port to the TClientSocket??
Is that assign at the object inspector or at runtime??

George Tokas.

Author Comment

ID: 17169359
In response to gtokas' question, I am setting the Service and Host/Address properties of the TClientSocket at design time through the object inspector.

In response to cwwkie's comment, I pared the code down to its essentials, changed the POST message to a GET message and changed the host to, and I got the same results.  Here's the code:

    (TClientSocket ClientSocket1 has the following properties set through the Object Inspector:
    Active = false
    Address = ""
    ClientType = ctBlocking
    Host =
    Port = 0
    Service = http
    Tag = 0)

    void __fastcall TdlgInputUCID::Button2Click(TObject *Sender)
            logout("KISLog.txt", "Here1");
            //This prints "Here1\n" to "KISLog.txt".  I'm using it to track what lines I actually reach when the program
            logout("KISLog.txt", "Here2");
            logout("KISLog.txt", "Here3");
            logout("KISLog.txt", "Here4");
            logout("KISLog.txt", "Here5");

    void __fastcall TdlgInputUCID::ClientSocket1Lookup(TObject *Sender,
          TCustomWinSocket *Socket)
            logout("KISLog.txt", "Here7");
    dlgRegistering->lblMessage->Caption = "Looking up registration site...";
            logout("KISLog.txt", "Here8");
            logout("KISLog.txt", "Here9");

    void __fastcall TdlgInputUCID::ClientSocket1Connecting(TObject *Sender,
          TCustomWinSocket *Socket)
            logout("KISLog.txt", "Here10");
    dlgRegistering->lblMessage->Caption = "Connecting to registration site...";
            logout("KISLog.txt", "Here11");
            logout("KISLog.txt", "Here12");
        AnsiString Out = "Address = " + ClientSocket1->Address + " ";
        Out[Out.Length()] = 0;
        logout("KISLog.txt", &(Out[1]));
        Out = "Port = " + (AnsiString)ClientSocket1->Port + " ";
        Out[Out.Length()] = 0;
        logout("KISLog.txt", &(Out[1]));

    void __fastcall TdlgInputUCID::ClientSocket1Connect(TObject *Sender,
          TCustomWinSocket *Socket)
            logout("KISLog.txt", "Here13");
    TWinSocketStream* MySocketStream = new TWinSocketStream(Socket, 10000);
            logout("KISLog.txt", "Here14");

    AnsiString CurrentBuffer, TotalReturn;
    AnsiString PostMessage = "GET /index.html HTTP/1.1\nHost:\n\n";
    CurrentBuffer = " ";
    TotalReturn = "";
    int Test;
    lblRegStr->Caption = "";
            logout("KISLog.txt", "Here15");
          AnsiString Out = "Address = " + ClientSocket1->Address + " ";
          Out[Out.Length()] = 0;
          logout("KISLog.txt", &(Out[1]));
          Out = "Port = " + (AnsiString)ClientSocket1->Port + " ";
          Out[Out.Length()] = 0;
          logout("KISLog.txt", &(Out[1]));
              logout("KISLog.txt", "Here16");
      dlgRegistering->lblMessage->Caption = "Sending Registration Information...";
        Test = MySocketStream->Read(&(CurrentBuffer[1]), 1);
        if (Test)
          TotalReturn = TotalReturn + CurrentBuffer;
        }while ((Test > 0));
      TotalReturn = TotalReturn + " ";
      TotalReturn[TotalReturn.Length()] = 0;
      logout("KISLog.txt", &(TotalReturn[1]));
      //If the connection is successful, this prints out the index.html in KISLog.txt.
              logout("KISLog.txt", "Here17");
      lblRegStr->Caption = "timeout";
    delete MySocketStream;
    void __fastcall TdlgInputUCID::ClientSocket1Disconnect(TObject *Sender,
          TCustomWinSocket *Socket)
            logout("KISLog.txt", "Here18");
    dlgRegistering->lblMessage->Caption = "Disconnected";
            logout("KISLog.txt", "Here19");
            logout("KISLog.txt", "Here20");

    void __fastcall TdlgInputUCID::ClientSocket1Error(TObject *Sender,
          TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
            logout("KISLog.txt", "Here21");
    AnsiString ErrorMessage = "Error " + (AnsiString)ErrorEvent + "\n";
      case eeGeneral:
      ErrorMessage = ErrorMessage + "The socket received an error\nmessage that does not fit into\nany of the
        following categories.";

      case eeSend:
      ErrorMessage = ErrorMessage + "An error occurred when trying\nto write to the socket connection.";

      case eeReceive:
      ErrorMessage = ErrorMessage + "An error occurred when trying\nto read from the socket connection.";

      case eeConnect:
      ErrorMessage = ErrorMessage + "A connection request that was\nalready accepted could not be\ncompleted.";

      case eeDisconnect:
      ErrorMessage = ErrorMessage + "An error occurred when trying\nto close a connection.";

      case eeAccept:
      ErrorMessage = ErrorMessage + "A problem occurred when trying\nto accept a client connection request.";
            logout("KISLog.txt", "Here22");
    Application->MessageBox(ErrorMessage.c_str(), "");
            logout("KISLog.txt", "Here23");
    ErrorCode = 0;

When I run this on Windows XP, everything works.

When I run this on Windows 98SE, I get the "Error 10049 on connect", and the KISLog.txt reads
    Address =
    Port = 0
Indicating that it looked up the site, tried to connect, disconnected without entering the OnConnect event, got the "(10049) on API 'connect' " error without entering the OnError event, and aborted the Button2Click program without finishing up.  (I had to close dlgRegistering manually)

> This behavior is strange...
That's what I thought, and why I'm open to just about any workaround. ;)
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

LVL 14

Accepted Solution

cwwkie earned 250 total points
ID: 17187971
I think it is a kind of timing issue. When I run it on a win9X box with a firewall, I get the dns lookup popup AFTER the error message.

Maybe you can try ICS ( I could use it's WSocket without any problem. I have no time to create a larger test program, but at least the connect is working on win9X.

I have two unrelated comments;

Instead of writing to a log file, OutputDebugString can be usefull in combination with Debugview (

To try it, you can use this define without any further changes in the code:
#define logout(f,txt) OutputDebugString(txt)
If you run the program from within the ide, the strings will be sent to the internal event viewer.

>        AnsiString Out = "Address = " + ClientSocket1->Address + " ";
>        Out[Out.Length()] = 0;
>        logout("KISLog.txt", &(Out[1]));

It is easier to do this:
        AnsiString Out = "Address = " + ClientSocket1->Address + " ";
        logout("KISLog.txt", Out.c_str());

Author Comment

ID: 17188740
Thanks, cwwkie.

I just downloaded ICS, and I'll get back to you as soon as I know whether it works.

Author Comment

ID: 17197291
Thanks again, cwwkie.

ICS's WSocket just checked out on my Win 98SE computer, and I couldn't ask for more.

Just a few interesting (& undocumented) installation hang-ups, which I will post later.  (Right now, there's a severe thunderstorm warning).

But, problem is solved

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now