🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4721

Windows socket error 10057

#4721
From: Jeremy
Date: Thu, 06 Jan 2005 14:43
127 lines
5083 bytes
Whenever I try to send something over my socket, I get the 
following error on the server side:

"Project Receiver.exe raised exception class ESocketError
with message 'Windows socket error: A request to send
or receive data was disallowed because the socket is not
connected and (when sending on a datagram socket using a
sendto call) no address was supplied (10057), on API 'recv'."

On the client side, I get the following error message:

"Project Trans.exe raised exception class ESocket Error with
message 'Asynchronous socket error 10053'."

I'm fairly certain that the socket is connected since the
OnConnect events occur for both the client and the server.
I only Click the Send button after I have diplayed the
"Connected to : . . ." in the status bar (indicating that
the OnConnect event has occured). Am I using the localhost
address improperly? Am I using the ReceiveText function
incorrectly? I have posted my code below.

I'm new to both Borland and network programming, so please 
excuse my ignorance if the solution is something simple.

Thanks for your help,
Jeremy

Here is the code I'm using:
//*******************************
//-------------------------------
//This is the code for my client:
//-------------------------------
//--------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//--------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------
void __fastcall TForm1::OpenButtonClick(TObject *Sender)
{
    Form1->ClientSocket1->Host = "127.0.0.1";
    Form1->ClientSocket1->Port = 1024;
    Form1->ClientSocket1->Open();
}
//--------------------------------------------------------------
void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
      TCustomWinSocket *Socket)
{
    StatusBar1->SimpleText = "Connected to: " 
                              + Socket->RemoteHost;
}
//--------------------------------------------------------------
void __fastcall TForm1::ClientSocket1Disconnect(TObject *Sender,
      TCustomWinSocket *Socket)
{
    StatusBar1->SimpleText = "Disconnected";
}
//--------------------------------------------------------------
void __fastcall TForm1::CloseButtonClick(TObject *Sender)
{
        Form1->ClientSocket1->Close();
}
//--------------------------------------------------------------

void __fastcall TForm1::SendButtonClick(TObject *Sender)
{
      AnsiString message = "Got it";
      Form1->ClientSocket1->Socket->SendText(message);
}
//--------------------------------------------------------------


//*******************************
//*******************************
//-------------------------------
//This is the code for my server:
//-------------------------------
//--------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//--------------------------------------------------------------

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//--------------------------------------------------------------

void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject 
*Sender, TCustomWinSocket *Socket)
{
    StatusBar1->SimpleText = "Listening";
}
//--------------------------------------------------------------

void __fastcall TForm1::ServerSocket1ClientConnect(TObject 
*Sender, TCustomWinSocket *Socket)
{
    StatusBar1->SimpleText = "Connected to: " 
                              + Socket->RemoteHost;
}
//--------------------------------------------------------------

void __fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
      TCustomWinSocket *Socket)
{
    Edit1->Text = Form1->ServerSocket1->Socket
                       ->ReceiveText();        
}
//--------------------------------------------------------------
Technical Details
Message-ID: <41dd4e96$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,13e3a9a3d358153e,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Jeremy" <jeremy@none.com>
Sender: "Jeremy" <jeremy@none.com>
Reply-To: "Jeremy" <jeremy@none.com>
Subject: Windows socket error 10057
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 205.175.225.22     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41dd4e96$1@newsgroups.borland.com>
Date: 6 Jan 2005 06:43:34 -0800
X-Trace: newsgroups.borland.com 1105022614 207.105.83.66 (6 Jan 2005 06:43:34 -0800)
Lines: 127
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail