{"action":"closed","issue":{"url":"https://api.github.com/repos/dump247/udt-net/issues/28","repository_url":"https://api.github.com/repos/dump247/udt-net","labels_url":"https://api.github.com/repos/dump247/udt-net/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/dump247/udt-net/issues/28/comments","events_url":"https://api.github.com/repos/dump247/udt-net/issues/28/events","html_url":"https://github.com/dump247/udt-net/issues/28","id":141223961,"number":28,"title":"How to match UDT performance over LAN with that of TCP","user":{"login":"judef","id":63353,"avatar_url":"https://avatars.githubusercontent.com/u/63353?v=3","gravatar_id":"","url":"https://api.github.com/users/judef","html_url":"https://github.com/judef","followers_url":"https://api.github.com/users/judef/followers","following_url":"https://api.github.com/users/judef/following{/other_user}","gists_url":"https://api.github.com/users/judef/gists{/gist_id}","starred_url":"https://api.github.com/users/judef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judef/subscriptions","organizations_url":"https://api.github.com/users/judef/orgs","repos_url":"https://api.github.com/users/judef/repos","events_url":"https://api.github.com/users/judef/events{/privacy}","received_events_url":"https://api.github.com/users/judef/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-16T10:01:28Z","updated_at":"2016-04-26T17:07:57Z","closed_at":"2016-04-26T17:07:57Z","body":"While trying to send 233MB file using UDT from windows desktop app to NAS storage drive over LAN takes around 40 secs, if we directly copy the file to NAS storage it takes 23 secs. We have a 100 Mbps Ethernet connection. Below is our code to send and receive file. What params need to be set to ideally match the speed of TCP over LAN(SendBufferSize/MaxBandwidth). Any help would be greatly appreciated.\r\n\r\nClient:\r\n```vb\r\nUsing client As New Udt.Socket(AddressFamily.InterNetwork, SocketType.Stream)\r\n                Using fs As New Udt.StdFileStream(file, FileMode.Open)\r\n                    ''client.SendBufferSize = 102400000\r\n                    client.Connect(ReturnIP4Address(remoteHostEntry), Integer.Parse(UserServer.PORT))\r\n                    client.MaxBandwidth = 102400000\r\n\r\n                    fileNameCumLength = fs.Length & \"~\" & ServerPath & FolderName & RemoveSpecialCharacters(Path.GetFileName(file))\r\n                    fileInfoLength = System.Text.Encoding.ASCII.GetBytes(CStr(fileNameCumLength).ToCharArray()).Length\r\n\r\n                    'file size & name\r\n                    client.Send(BitConverter.GetBytes(fileInfoLength), 0, 8)\r\n                    client.Receive(strRec)\r\n                    ''\r\n                    While rsize2 < fileInfoLength\r\n                        'file info\r\n                        rs2 = client.Send(System.Text.Encoding.ASCII.GetBytes(CStr(fileNameCumLength).ToCharArray()), rsize2, fileInfoLength - rsize2)\r\n                        rsize2 += rs2\r\n                    End While\r\n                    client.Receive(strRec)\r\n                    'end file size and name\r\n\r\n                    'sent file\r\n                    ''Dim dt As Udt.TraceInfo = client.GetPerformanceInfo()\r\n                    client.SendFile(fs)\r\n                    client.Receive(strRec, 0, 4)\r\n                    'end send file\r\n                    client.Close()\r\n                End Using\r\n            End Using\r\n```\r\nServer:\r\n```vb\r\nPublic Sub UDPReceive()\r\n        Try\r\n\r\n            While True\r\n                Using server As New Udt.Socket(AddressFamily.InterNetwork, SocketType.Stream)\r\n                    ''server.ReceiveBufferSize = 102400000\r\n                    server.Bind(IPAddress.Any, UDPPORT)\r\n                    Console.WriteLine(\"Server is ready at PORT: {0}\", UDPPORT)\r\n                    server.Listen(100)\r\n\r\n                    While True\r\n                        DclientAcceptSocket = server.Accept()\r\n                        Dim cc As New DClientConnection(DclientAcceptSocket)\r\n                        UDPThread = New Thread(New ThreadStart(AddressOf cc.DUDPProcess))\r\n                        UDPThread .Start()\r\n                    End While\r\n                    server.Close()\r\n                End Using\r\n            End While\r\n\r\n        Catch ex As Exception\r\n            UDPThread .Abort()\r\n            UDPReceive()\r\n        End Try\r\n    End Sub\r\n\r\n    Public Class DClientConnection\r\n        Private client As Udt.Socket\r\n\r\n        Public Sub New(cc As Udt.Socket)\r\n            Try\r\n                Me.client = cc\r\n            Catch ex As Exception\r\n\r\n            End Try\r\n        End Sub\r\n\r\n        Public Sub DUDPProcess()\r\n            Try\r\n                ' Receive file name from client\r\n                Dim bytFilelength As Byte() = New Byte(1023) {}\r\n                Dim bytFilename As Byte() = New Byte(1023) {}\r\n                Dim intFileNameLength As Integer\r\n                Dim lgFilelength As Long\r\n                Dim strName As String\r\n                Dim rs As Long = 0\r\n                Dim rsize As Long = 0\r\n                Dim BytesToSend As Long = 0\r\n\r\n                client.MaxBandwidth = 102400000\r\n\r\n                'receive file length & path\r\n                client.Receive(bytFilelength, 0, 1024)\r\n                client.Send(BitConverter.GetBytes(True))\r\n\r\n                intFileNameLength = BitConverter.ToInt32(bytFilelength, 0)\r\n                bytFilename = New Byte(intFileNameLength - 1) {}\r\n                'file info\r\n                While rsize < intFileNameLength\r\n                    rs = client.Receive(bytFilename, rsize, intFileNameLength - rsize)\r\n                    rsize += rs\r\n                End While\r\n                strName = Encoding.UTF8.GetString(bytFilename)\r\n\r\n                'File size\r\n                lgFilelength = CType(strName.Split(\"~\")(0), Long)\r\n                'File Name\r\n                strName = strName.Split(\"~\")(1)\r\n\r\n                Console.WriteLine(\"length: {0}\", lgFilelength)\r\n                Console.WriteLine(\"name: {0}\", strName)\r\n\r\n                client.Send(BitConverter.GetBytes(True))\r\n                'End receive file length & path\r\n                \r\n                'Receive file\r\n                client.ReceiveFile(strName, lgFilelength)\r\n\r\n                'send so that client may not exit as soon as sends\r\n                client.Send(BitConverter.GetBytes(1), 0, 4)\r\n                client.Close()\r\n\r\n                client.Dispose()\r\n            Catch ex As Exception\r\n                client.Dispose()\r\n            End Try\r\n        End Sub\r\n    End Class\r\n```"}}