| View previous topic :: View next topic |
| Author |
Message |
Jonathan Benedicto Guest
|
Posted: Sat Feb 19, 2005 8:01 pm Post subject: Socket Error # 10040 Message To Long |
|
|
I'm building an application that transmite data packets using the Indy UDP
set.
But, I've been encountering a exception being thrown in my code. The
exception is Socket Error # 10040 Message too long.
The exception happens right at this line, where DataSize is a int.
if(UdpClient->ReceiveBuffer(&DataSize, sizeof(int), 1000) == sizeof(int)){
Is the remote server (I built this too) sending too much data, or have I not
built this client right.
Thank you for any help.
--
Jonathan
|
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Sat Feb 19, 2005 11:44 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
Jonathan Benedicto wrote:
| Quote: | But, I've been encountering a exception being thrown in my code. The
exception is Socket Error # 10040 Message too long.
The exception happens right at this line, where DataSize is a int.
if(UdpClient->ReceiveBuffer(&DataSize, sizeof(int), 1000) == sizeof(int)){
|
Is that a TIdUDPClient ?
That doesn't look right.
I see 2 versions of ReceiveBuffer()
One with 2 arguments and one with 4.
Neither one has a size parameter.
(Indy 10 on-line manual)
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Feb 19, 2005 11:48 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
"Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote
| Quote: | But, I've been encountering a exception being thrown in my code.
The exception is Socket Error # 10040 Message too long.
|
WSAEMSGSIZE
(10040)
Message too long.
A message sent on a datagram socket was larger than the internal message
buffer or some other network limit, or the buffer used to receive a datagram
into was smaller than the datagram itself.
Gambit
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Sat Feb 19, 2005 11:53 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
Yes it is TIdUDPClient. I use Indy 9, and my compiler didn't give any
errors. I'll have to check that.
--
Jonathan
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> wrote
| Quote: | Jonathan Benedicto wrote:
But, I've been encountering a exception being thrown in my code. The
exception is Socket Error # 10040 Message too long.
The exception happens right at this line, where DataSize is a int.
if(UdpClient->ReceiveBuffer(&DataSize, sizeof(int), 1000) == sizeof(int)){
Is that a TIdUDPClient ?
That doesn't look right.
I see 2 versions of ReceiveBuffer()
One with 2 arguments and one with 4.
Neither one has a size parameter.
(Indy 10 on-line manual)
|
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Sat Feb 19, 2005 11:55 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
Do you think it is caused by my reading just a int-sized chunk of the
datagram ? Because I don't know how long the datagram is going to be. That
first int is a length.
--
Jonathan
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote
| Quote: |
WSAEMSGSIZE
(10040)
Message too long.
A message sent on a datagram socket was larger than the internal message
buffer or some other network limit, or the buffer used to receive a
datagram
into was smaller than the datagram itself.
Gambit
|
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Sun Feb 20, 2005 12:34 am Post subject: Re: Socket Error # 10040 Message To Long |
|
|
I just checked it, and in Indy 9, the ReceiveBuffer methods take 3 and
5 parameters.
--
Jonathan
|
|
| Back to top |
|
 |
Chad Z. Hower aka Kudzu Guest
|
Posted: Tue Feb 22, 2005 2:10 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
"Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote in
news:4217d1de (AT) newsgroups (DOT) borland.com:
| Quote: | Do you think it is caused by my reading just a int-sized chunk of the
datagram ? Because I don't know how long the datagram is going to be. That
first int is a length.
|
Yes. You need to limit yourself. Windows has a max of 32k, some routers less.
To be ultra safe, stick to 1k. Ive found in practice that 8k works pretty
reliably though.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Want more Indy stuff? Try the Atozed Indy Portal at
http://www.atozedsoftware.com/
* More Free Demos
* Free Articles
* Extra Support
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Tue Feb 22, 2005 4:38 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
Thank you for this info. I'm going to change how my system works, so
that it send / receives a max of 204 bytes.
--
Jonathan
| Quote: | Yes. You need to limit yourself. Windows has a max of 32k, some
routers less.
To be ultra safe, stick to 1k. Ive found in practice that 8k works
pretty
reliably though.
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Feb 22, 2005 6:47 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
"Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote
| Quote: | Do you think it is caused by my reading just a int-sized
chunk of the datagram ?
|
No. The datagram itself is too large for the socket to buffer internally
before your own code then reads it from the buffer. Once in the buffer, it
doesn't matter how your code reads it. But the socket has to receive and
buffer it first, and that is where the error is coming from.
Gambit
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Tue Feb 22, 2005 8:59 pm Post subject: Re: Socket Error # 10040 Message To Long |
|
|
| Quote: | No. The datagram itself is too large for the socket to buffer
internally
before your own code then reads it from the buffer. Once in the
buffer, it
doesn't matter how your code reads it. But the socket has to
receive and
buffer it first, and that is where the error is coming from.
|
When I changed the code to read 8192 bytes into a memory stream, then
the error disappeared. I did tests on it, and it did seem like the
error was caused by the tiny read.
For example, this code does not give a error :
TMemoryStream* s = new TMemoryStream();
s->SetSize(8192);
int size = UdpClient->ReceiveBuffer(s->Memory, s->Size, 1000);
But this code returns a message too long error :
int size = UdpClient->ReceiveBuffer(buffer, 4, 1000);
|
|
| Back to top |
|
 |
|