Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys,

When I receive data sent from one application to another application I get an error. One application acts as the server and sends data to the client that connected to the server on a particular port.
I sent some information via clientsocket and at that time I got this error.

"Specified argument was out of the range of valid values.Parameter name: size"

Here my coding ...

VB
Dim bytesFrom(10024) As Byte

networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize))


clientSocket.ReceiveBufferSize is 505196.

I don't understand this problem. Can anyone help please?


Regards,

Saran.t
Posted
Updated 9-Jul-20 14:37pm
v3
Comments
Manfred Rudolf Bihy 25-Dec-10 3:14am    
Edited for spelling and grammar, added code tags, concise title.
Manfred Rudolf Bihy 25-Dec-10 3:52am    
Did you get it to work yet?
Manfred Rudolf Bihy 27-Dec-10 11:16am    
Did you you vote a 3? What was that for if I answered your question?

The problem is with the argument CInt(clientSocket.ReceiveBufferSize in invocation of function Read.
Besides that why would you want to read 505196 bytes into an array that can only take 10024 bytes, is this a typo and you wanted to say your bytesFrom buffer was even only 1024 bytes.

Explanation:

If the size of buffer is less than the size parameter of NetworkStream.Read function an ArgumentOutOfRange Exception is thrown.

See here: http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.read.aspx[]

Please make the amount of bytes you want to read smaller or equal to the size of your buffer.


Cheers,


Manfred
 
Share this answer
 
v3
mesmo colocando 1024 nao funcionou
 
Share this answer
 
Comments
CHill60 10-Jul-20 5:56am    
Esta não é uma resposta! Use "Have a Question or Comment?" para fazer um comentário. Além disso, você deve usar inglês aqui , por favor

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900