Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2006-07-18
Medium Priority
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 www.ducksnm.com, 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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 ee-stuff.com (http://www.ee-stuff.com/Expert/Upload/viewFilesQuestion.php?qid=21923611)
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 www.nmia.com, 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 = www.nmia.com
    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: www.nmia.com\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. ;)

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 14

Accepted Solution

cwwkie earned 1000 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 (http://www.overbyte.be/frame_index.html?redirTo=/products/ics.html) 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 (http://www.sysinternals.com/Utilities/DebugView.html)

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

730 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