Article View: borland.public.cppbuilder.internet.socket
Article #770TServerSocket/TClientSocket send buffer error 10053 and 10057
From: newsgroups.borland.com
Date: Sun, 28 Oct 2007 16:54
Date: Sun, 28 Oct 2007 16:54
87 lines
3578 bytes
3578 bytes
Hi all,
I'm developing a simple audio streamer over LAN.
I have a TServerSocket in non-blocking listening on port 5678.
Then I have a TClientSocket that connect to the server.
When one or more connections are ready, the server receive 1000 byte chunk
of wav data from the sound card and send to all the connected clients.
On the client side when a 1000 byte chunk is received it's buffered, then
sent to the sound card.
It seems to work fine for some time, then the error 10053 appears.
What I'm doing wrong?
Thanks in advance.
Lapo
-------------------------------
this is the snip of the code
SERVER SIDE:
when a 1000 bytes chunk arrives, Data point to the buffer and BytesReaded is
the size (usually 1000)
if(TCPLive->Socket->ActiveConnections>0) {
for(int i=0;i<TCPLive->Socket->ActiveConnections;i++) {
TCustomWinSocket *Client=TCPLive->Socket->Connections[i];
if(Client!=NULL) {
try {
if(Client->Connected) {
Client->SendBuf(Data, BytesReaded);
}
}
catch(Exception &e) {
LogLine("Error sending to "+Client->RemoteHost+": "+e.Message);
}
}
}
}
CLIENT SIDE:
TLiveBuffer is a simple class with two members: BufferSize with the buffer
length and Buffer that will point to a membuffer.
TLiveWaveOut is a class that read TLiveBuffer list, send to the soundcard
and free the buffers.
void __fastcall TForm1::TCPRead(TObject *Sender, TCustomWinSocket *Socket)
{
int BuffersCount=0;
int len=Socket->ReceiveLength();
if(len>=LiveWaveOut->BufferSize)
len=LiveWaveOut->BufferSize;
char *buffer=new char[len];
char *subbuffer=buffer;
try {
Socket->ReceiveBuf(buffer, len);
TList *Buffers=BuffersList->LockList();
try {
while(len>0) {
TLiveBuffer *Chunk=new TLiveBuffer;
if(len>=LiveWaveOut->BufferSize) {
Chunk->BufferSize=LiveWaveOut->BufferSize;
Chunk->Buffer=new char [LiveWaveOut->BufferSize];
memcpy(Chunk->Buffer, subbuffer, LiveWaveOut->BufferSize);
}
else {
Chunk->BufferSize=len;
Chunk->Buffer=new char [Chunk->BufferSize];
memcpy(Chunk->Buffer, subbuffer, Chunk->BufferSize);
}
BuffersCount=Buffers->Add(Chunk);
len-=Chunk->BufferSize;
subbuffer+=Chunk->BufferSize;
}
}
__finally {
BuffersList->UnlockList();
}
}
__finally {
delete buffer;
}
}
Technical Details
Message-ID:
<4724bebc@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.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-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f596705b7af33f46,start X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "newsgroups.borland.com" <lapoguidi@alice.it> Newsgroups: borland.public.cppbuilder.internet.socket Subject: TServerSocket/TClientSocket send buffer error 10053 and 10057 Date: Sun, 28 Oct 2007 17:54:01 +0100 Lines: 88 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545 NNTP-Posting-Host: 87.24.165.170 Message-ID: <4724bebc@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1193590460 87.24.165.170 (28 Oct 2007 09:54:20 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.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