Im making an app that will be sending data of 1MB length. Bellow is my testing code which is just sending a simple byte array of 1MB, However it keeps throwing the bellow exception even when I try increasing the send buffer to 1MB or above.
Code
private void sendattack(string ip, int port)
{
IPEndPoint RemoteEndPoint = new IPEndPoint(IPAddress.Parse(ip), port);
Socket serversoc = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
char[] data = new char[100000];
var send = Encoding.ASCII.GetBytes(data);
serversoc.SendTo(send, send.Length, SocketFlags.None, RemoteEndPoint);
}
Error
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
System.Net.Sockets.SocketException was unhandled ErrorCode=10040 HResult=-2147467259 Message=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 NativeErrorCode=10040 Source=System StackTrace: at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP) at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 size, SocketFlags socketFlags, EndPoint remoteEP) at qnet.svchost.sendattack(String ip, Int32 port) in C:\Users\User\OneDrive\Documents\Visual Studio 2013\Projects\qnet\qnet\svchost.cs:line 84 at qnet.svchost.Form1_Load(Object sender, EventArgs e) in C:\Users\User\OneDrive\Documents\Visual Studio 2013\Projects\qnet\qnet\svchost.cs:line 27 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) InnerException: