C# Socket Programming

  • Thread starter Thread starter maxpa1n
  • Start date Start date
M

maxpa1n

Hi

i am a software developer and i need to use .NET 2.0 with C#.

I am using Visual Studio 2005 Professional and Windows Vista Ultimate
as the development eviornment.

I have a programm that uses the System.Net.Socket.Socket class.

So i have init a UDP socket like socket with the
AddressFamily.InterNetwork, SocketType.Dgram and the ProtocolType.UDP.

At this point everything is all right, now i try to send a byte array
using mysocket.SendTo with a size of 70000, and now i get a
SocketException that say the internal Buffer size is either to small
or to big to be send or recieved by the other endpoint.

The internal error code is 10040.

I looked up the error code on msdn but this information is pretty
leaky to me because it says the same as the exception.

I found an article which describes the catching of this exception and
simply add the size to the byte array and try to send it again, but
this makes no sens to me, because the other side has a big engouth
buffer to get this message so why do i need to increas my buffer
size ?

So anybody who has network expirience, could please say me why the
internal buffer is either to small or to big to be send, by the way i
tought using UDP it is not important how big or small a buffer can be,
this is quit confusing :/
 
Hi

i am a software developer and i need to use .NET 2.0 with C#.

I am using Visual Studio 2005 Professional and Windows Vista Ultimate
as the development eviornment.

I have a programm that uses the System.Net.Socket.Socket class.

So i have init a UDP socket like socket with the
AddressFamily.InterNetwork, SocketType.Dgram and the ProtocolType.UDP.

At this point everything is all right, now i try to send a byte array
using mysocket.SendTo with a size of 70000, and now i get a
SocketException that say the internal Buffer size is either to small
or to big to be send or recieved by the other endpoint.

The internal error code is 10040.

I looked up the error code on msdn but this information is pretty
leaky to me because it says the same as the exception.

I found an article which describes the catching of this exception and
simply add the size to the byte array and try to send it again, but
this makes no sens to me, because the other side has a big engouth
buffer to get this message so why do i need to increas my buffer
size ?

So anybody who has network expirience, could please say me why the
internal buffer is either to small or to big to be send, by the way i
tought using UDP it is not important how big or small a buffer can be,
this is quit confusing :/

Ok got it, due to IP protocol limitation it is not possible to send
more than 65507 bytes over IP / UDP protocol, u need to split or chunk
the data to get a big data transfare done : / poor I :P
 
maxpa1n said:
Ok got it, due to IP protocol limitation it is not possible to send
more than 65507 bytes over IP / UDP protocol, u need to split or chunk
the data to get a big data transfare done : / poor I :P

65535 bytes max size for IP packet, minus what is needed for IP and UDP
header, which varies based on the IP options.

However, the packet will be fragmented on your network (Ethernet max segment
size is 1536 bytes, minus Ethernet header), so now if any one of the ~50
pieces is lost your whole message is lost.

Why are you not using TCP?
 
Back
Top