├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── LICENSE.Apachev2
├── LICENSE.BSD
├── README.md
├── build.sh
├── make_common.mak
├── make_linux.mak
├── make_macosx.mak
├── make_windows.mak
├── src
├── api.cpp
├── api.h
├── buffer.cpp
├── buffer.h
├── cache.cpp
├── cache.h
├── ccc.cpp
├── ccc.h
├── channel.cpp
├── channel.h
├── core.cpp
├── core.h
├── epoll.cpp
├── epoll.h
├── list.cpp
├── list.h
├── md5.cpp
├── md5.h
├── packet.cpp
├── packet.h
├── queue.cpp
├── queue.h
├── udt.h
├── udtCommon.cpp
├── udtCommon.h
├── window.cpp
└── window.h
└── udt-doc
├── 0001-Added-BARCHART-2013-05-11-2013-05-12-already-applied.patch
├── 0002-Refactored-win-osx-and-32-64-bit-preprocessor-symbol.patch
├── 0003-Code-polish.-removed-unnecessary-preprocessor-symbol.patch
├── 0004-Fixed-unitialized-variable.patch
├── LICENSE.txt
├── README.txt
├── RELEASE_NOTES.txt
├── draft-gg-udt-xx.txt
├── udt-2009.ppt
└── udt-sc08-poster.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3 |
4 | # User-specific stuff:
5 | .idea/**/workspace.xml
6 | .idea/**/tasks.xml
7 | .idea/dictionaries
8 | .idea/**/codeStyles/
9 | .idea/**/codeStyleSettings.xml
10 |
11 | # Sensitive or high-churn files:
12 | .idea/**/dataSources/
13 | .idea/**/dataSources.ids
14 | .idea/**/dataSources.xml
15 | .idea/**/dataSources.local.xml
16 | .idea/**/sqlDataSources.xml
17 | .idea/**/dynamic.xml
18 | .idea/**/uiDesigner.xml
19 | .idea/**/shelf/
20 |
21 |
22 | # Gradle:
23 | .idea/**/gradle.xml
24 | # .idea/**/libraries # we want to include our library definitions.
25 |
26 | # CMake
27 | cmake-build-debug/
28 |
29 | # Mongo Explorer plugin:
30 | .idea/**/mongoSettings.xml
31 |
32 | ## File-based project format:
33 | *.iws
34 |
35 | ## Plugin-specific files:
36 |
37 |
38 | # IntelliJ
39 | out/
40 |
41 | # mpeltonen/sbt-idea plugin
42 | .idea_modules/
43 |
44 | # JIRA plugin
45 | atlassian-ide-plugin.xml
46 |
47 | # Cursive Clojure plugin
48 | .idea/replstate.xml
49 |
50 | # Crashlytics plugin (for Android Studio and IntelliJ)
51 | com_crashlytics_export_strings.xml
52 | crashlytics.properties
53 | crashlytics-build.properties
54 | fabric.properties
55 |
56 | ######################
57 | # End JetBrains IDEs #
58 | ######################
59 |
60 | /bin/
61 | /dist/
62 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | PROJECT( udt )
2 | cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
3 |
4 | if (CMAKE_BUILD_TYPE STREQUAL "Debug")
5 | add_definitions(-D_DEBUG)
6 | endif()
7 |
8 | add_definitions(
9 | -Wall
10 | -D__UNIX
11 | -DPOSIX_C_SOURCE
12 | -DGNU_SOURCE
13 | -Wno-unused-function
14 | -std=c++11
15 | )
16 |
17 | SET(LIBRARIES
18 | pthread
19 | m
20 | ${ARCAN_SHMIF_LIBRARY}
21 | )
22 |
23 | set(SOURCES
24 | src/api.cpp
25 | src/buffer.cpp
26 | src/cache.cpp
27 | src/ccc.cpp
28 | src/channel.cpp
29 | src/core.cpp
30 | src/epoll.cpp
31 | src/list.cpp
32 | src/md5.cpp
33 | src/packet.cpp
34 | src/queue.cpp
35 | src/udtCommon.cpp
36 | src/window.cpp
37 | )
38 |
39 | add_library(${PROJECT_NAME} ${SOURCES})
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | - UDT Build System - Apache 2.0 License
2 | https://github.com/dorkbox
3 | Copyright 2015, dorkbox, llc
4 |
5 |
6 |
7 | - Barchart UDT - BSD License
8 | https://github.com/barchart/barchart-udt
9 | Copyright 2009-2013, Barchart, Inc.
10 |
11 |
12 |
13 | - UDTv4 - BSD License
14 | http://udt.sourceforge.net/
15 | Copyright 2001 - 2011, The Board of Trustees of the University of Illinois
16 |
--------------------------------------------------------------------------------
/LICENSE.Apachev2:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining a
16 | copy of this software and associated documentation files (the "Software"),
17 | to deal in the Software without restriction, including without limitation
18 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 | and/or sell copies of the Software, and to permit persons to whom the
20 | Software is furnished to do so, subject to the following conditions:
21 |
22 | The above copyright notice and this permission notice shall be included
23 | in all copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31 | DEALINGS IN THE SOFTWARE.
32 | "Legal Entity" shall mean the union of the acting entity and all
33 | other entities that control, are controlled by, or are under common
34 | control with that entity. For the purposes of this definition,
35 | "control" means (i) the power, direct or indirect, to cause the
36 | direction or management of such entity, whether by contract or
37 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
38 | outstanding shares, or (iii) beneficial ownership of such entity.
39 |
40 | "You" (or "Your") shall mean an individual or Legal Entity
41 | exercising permissions granted by this License.
42 |
43 | "Source" form shall mean the preferred form for making modifications,
44 | including but not limited to software source code, documentation
45 | source, and configuration files.
46 |
47 | "Object" form shall mean any form resulting from mechanical
48 | transformation or translation of a Source form, including but
49 | not limited to compiled object code, generated documentation,
50 | and conversions to other media types.
51 |
52 | "Work" shall mean the work of authorship, whether in Source or
53 | Object form, made available under the License, as indicated by a
54 | copyright notice that is included in or attached to the work
55 | (an example is provided in the Appendix below).
56 |
57 | "Derivative Works" shall mean any work, whether in Source or Object
58 | form, that is based on (or derived from) the Work and for which the
59 | editorial revisions, annotations, elaborations, or other modifications
60 | represent, as a whole, an original work of authorship. For the purposes
61 | of this License, Derivative Works shall not include works that remain
62 | separable from, or merely link (or bind by name) to the interfaces of,
63 | the Work and Derivative Works thereof.
64 |
65 | "Contribution" shall mean any work of authorship, including
66 | the original version of the Work and any modifications or additions
67 | to that Work or Derivative Works thereof, that is intentionally
68 | submitted to Licensor for inclusion in the Work by the copyright owner
69 | or by an individual or Legal Entity authorized to submit on behalf of
70 | the copyright owner. For the purposes of this definition, "submitted"
71 | means any form of electronic, verbal, or written communication sent
72 | to the Licensor or its representatives, including but not limited to
73 | communication on electronic mailing lists, source code control systems,
74 | and issue tracking systems that are managed by, or on behalf of, the
75 | Licensor for the purpose of discussing and improving the Work, but
76 | excluding communication that is conspicuously marked or otherwise
77 | designated in writing by the copyright owner as "Not a Contribution."
78 |
79 | "Contributor" shall mean Licensor and any individual or Legal Entity
80 | on behalf of whom a Contribution has been received by Licensor and
81 | subsequently incorporated within the Work.
82 |
83 | 2. Grant of Copyright License. Subject to the terms and conditions of
84 | this License, each Contributor hereby grants to You a perpetual,
85 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86 | copyright license to reproduce, prepare Derivative Works of,
87 | publicly display, publicly perform, sublicense, and distribute the
88 | Work and such Derivative Works in Source or Object form.
89 |
90 | 3. Grant of Patent License. Subject to the terms and conditions of
91 | this License, each Contributor hereby grants to You a perpetual,
92 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93 | (except as stated in this section) patent license to make, have made,
94 | use, offer to sell, sell, import, and otherwise transfer the Work,
95 | where such license applies only to those patent claims licensable
96 | by such Contributor that are necessarily infringed by their
97 | Contribution(s) alone or by combination of their Contribution(s)
98 | with the Work to which such Contribution(s) was submitted. If You
99 | institute patent litigation against any entity (including a
100 | cross-claim or counterclaim in a lawsuit) alleging that the Work
101 | or a Contribution incorporated within the Work constitutes direct
102 | or contributory patent infringement, then any patent licenses
103 | granted to You under this License for that Work shall terminate
104 | as of the date such litigation is filed.
105 |
106 | 4. Redistribution. You may reproduce and distribute copies of the
107 | Work or Derivative Works thereof in any medium, with or without
108 | modifications, and in Source or Object form, provided that You
109 | meet the following conditions:
110 |
111 | (a) You must give any other recipients of the Work or
112 | Derivative Works a copy of this License; and
113 |
114 | (b) You must cause any modified files to carry prominent notices
115 | stating that You changed the files; and
116 |
117 | (c) You must retain, in the Source form of any Derivative Works
118 | that You distribute, all copyright, patent, trademark, and
119 | attribution notices from the Source form of the Work,
120 | excluding those notices that do not pertain to any part of
121 | the Derivative Works; and
122 |
123 | (d) If the Work includes a "NOTICE" text file as part of its
124 | distribution, then any Derivative Works that You distribute must
125 | include a readable copy of the attribution notices contained
126 | within such NOTICE file, excluding those notices that do not
127 | pertain to any part of the Derivative Works, in at least one
128 | of the following places: within a NOTICE text file distributed
129 | as part of the Derivative Works; within the Source form or
130 | documentation, if provided along with the Derivative Works; or,
131 | within a display generated by the Derivative Works, if and
132 | wherever such third-party notices normally appear. The contents
133 | of the NOTICE file are for informational purposes only and
134 | do not modify the License. You may add Your own attribution
135 | notices within Derivative Works that You distribute, alongside
136 | or as an addendum to the NOTICE text from the Work, provided
137 | that such additional attribution notices cannot be construed
138 | as modifying the License.
139 |
140 | You may add Your own copyright statement to Your modifications and
141 | may provide additional or different license terms and conditions
142 | for use, reproduction, or distribution of Your modifications, or
143 | for any such Derivative Works as a whole, provided Your use,
144 | reproduction, and distribution of the Work otherwise complies with
145 | the conditions stated in this License.
146 |
147 | 5. Submission of Contributions. Unless You explicitly state otherwise,
148 | any Contribution intentionally submitted for inclusion in the Work
149 | by You to the Licensor shall be under the terms and conditions of
150 | this License, without any additional terms or conditions.
151 | Notwithstanding the above, nothing herein shall supersede or modify
152 | the terms of any separate license agreement you may have executed
153 | with Licensor regarding such Contributions.
154 |
155 | 6. Trademarks. This License does not grant permission to use the trade
156 | names, trademarks, service marks, or product names of the Licensor,
157 | except as required for reasonable and customary use in describing the
158 | origin of the Work and reproducing the content of the NOTICE file.
159 |
160 | 7. Disclaimer of Warranty. Unless required by applicable law or
161 | agreed to in writing, Licensor provides the Work (and each
162 | Contributor provides its Contributions) on an "AS IS" BASIS,
163 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164 | implied, including, without limitation, any warranties or conditions
165 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166 | PARTICULAR PURPOSE. You are solely responsible for determining the
167 | appropriateness of using or redistributing the Work and assume any
168 | risks associated with Your exercise of permissions under this License.
169 |
170 | 8. Limitation of Liability. In no event and under no legal theory,
171 | whether in tort (including negligence), contract, or otherwise,
172 | unless required by applicable law (such as deliberate and grossly
173 | negligent acts) or agreed to in writing, shall any Contributor be
174 | liable to You for damages, including any direct, indirect, special,
175 | incidental, or consequential damages of any character arising as a
176 | result of this License or out of the use or inability to use the
177 | Work (including but not limited to damages for loss of goodwill,
178 | work stoppage, computer failure or malfunction, or any and all
179 | other commercial damages or losses), even if such Contributor
180 | has been advised of the possibility of such damages.
181 |
182 | 9. Accepting Warranty or Additional Liability. While redistributing
183 | the Work or Derivative Works thereof, You may choose to offer,
184 | and charge a fee for, acceptance of support, warranty, indemnity,
185 | or other liability obligations and/or rights consistent with this
186 | License. However, in accepting such obligations, You may act only
187 | on Your own behalf and on Your sole responsibility, not on behalf
188 | of any other Contributor, and only if You agree to indemnify,
189 | defend, and hold each Contributor harmless for any liability
190 | incurred by, or claims asserted against, such Contributor by reason
191 | of your accepting any such warranty or additional liability.
192 |
193 | END OF TERMS AND CONDITIONS
194 |
195 | APPENDIX: How to apply the Apache License to your work.
196 |
197 | To apply the Apache License to your work, attach the following
198 | boilerplate notice, with the fields enclosed by brackets "[]"
199 | replaced with your own identifying information. (Don't include
200 | the brackets!) The text should be enclosed in the appropriate
201 | comment syntax for the file format. We also recommend that a
202 | file or class name and description of purpose be included on the
203 | same "printed page" as the copyright notice for easier
204 | identification within third-party archives.
205 |
206 | Copyright [yyyy] [name of copyright owner]
207 |
208 | Licensed under the Apache License, Version 2.0 (the "License");
209 | you may not use this file except in compliance with the License.
210 | You may obtain a copy of the License at
211 |
212 | http://www.apache.org/licenses/LICENSE-2.0
213 |
214 | Unless required by applicable law or agreed to in writing, software
215 | distributed under the License is distributed on an "AS IS" BASIS,
216 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217 | See the License for the specific language governing permissions and
218 | limitations under the License.
--------------------------------------------------------------------------------
/LICENSE.BSD:
--------------------------------------------------------------------------------
1 | BSD License
2 |
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 |
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 |
13 | * Neither the name of the nor the names of its contributors
14 | may be used to endorse or promote products derived from this software
15 | without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL TINKERPOP BE LIABLE FOR ANY
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Breaking the Data Transfer Bottleneck
2 |
3 | UDT is a reliable UDP based application level data transport protocol for distributed data intensive applications
4 | over wide area high-speed networks. UDT uses UDP to transfer bulk data with its own reliability control and
5 | congestion control mechanisms. The new protocol can transfer data at a much higher speed than TCP does. UDT
6 | is also a highly configurable framework that can accommodate various congestion control algorithms.
7 | - Presentation: [PowerPoint](https://github.com/dorkbox/UDT/blob/master/udt-doc/udt-2009.ppt)
8 | - Poster: [PDF](https://github.com/dorkbox/UDT/blob/master/udt-doc/udt-sc08-poster.pdf)
9 |
10 | ### TCP
11 |
12 | TCP is [slow](http://barchart.github.com/barchart-udt/main/presentation-2009/img6.html).
13 | UDT is [fast](http://barchart.github.com/barchart-udt/main/presentation-2009/img9.html).
14 |
15 | ### UDT
16 |
17 | UDT is developed by [Yunhong Gu](http://www.linkedin.com/in/yunhong) and others at University of Illinois and Google.
18 |
19 | UDT C++ implementation is available under [BSD license](http://udt.sourceforge.net/license.html)
20 |
21 |
22 | ### Key Features
23 |
24 | **Fast**. UDT is designed for extremely high speed networks and it has been used to support global data transfer of terabyte sized data sets. UDT is the core technology in many commercial WAN acceleration products.
25 |
26 | **Fair and Friendly**. Concurrent UDT flows can share the available bandwidth fairly, while UDT also leaves enough bandwidth for TCP.
27 |
28 | **Easy to Use**. UDT resides completely at the application level. Users can simply download the software and start to use it. No kernel reconfiguration is needed. In addition, UDT's API is very similar to the traditional socket API so that existing applications can be easily modified.
29 |
30 | **Highly Configurable**. UDT supports user defined congestion control algorithms with a simple configuration. Users may also modify UDT to suit various situations. This feature can also be used by students and researchers to investigate new control algorithms.
31 |
32 | **Firewall Friendly**. UDT is completely based on UDP, which makes it easier to traverse the firewall. In addition, multiple UDT flows can share a single UDP port, thus a firewall can open only one UDP port for all UDT connections. UDT also supports rendezvous connection setup.
33 |
34 |
35 | ### Supported Platforms
36 |
37 | | ARCH/OS | Linux | Mac OSX | Windows |
38 | |--------------|---------|---------|---------|
39 | | arm-android | ??? | | |
40 | | arm-rpi | ??? | | |
41 | | x86/i386 | YES | YES | YES |
42 | | x86-64/amd64 | YES | YES | YES |
43 |
44 |
45 | ### Current Implementation
46 | - Updates to UDT source 4.11 to fix some misc. CPU timing bugs in Linux (via the sourceforge help forum).
47 | - Cleaned up source for cross-compile environment in linux
48 | - Cleaned up preprocessor symbols and removed deprecated
49 | - Strips unneeded symbols, drastically reducing size
50 | - Static linking to mingw libraries for windows build
51 |
52 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #*******************************************************************************
3 | #
4 | # This will build ALL variants!
5 | #
6 | # This expects the following environment variables set:
7 | #
8 | # COMPILE_OS - linux, macosx, windows
9 | # COMPILE_OS_ARCH - 32, 64, arm
10 | #
11 | #
12 | # possible packages you might need in order to compile:
13 | # gcc-4.8 gcc-4.8-multilib g++-4.8-multilib gdb make libgtk2.0-dev libxtst-dev libc6-dev-i386 mingw-w64
14 | # ccache libssl0.9.8
15 | #
16 | # Then, in gcc_apple_amd64 dir: sudo dpkg -i *.deb (this is 64bit gcc to build macosx binaries)
17 | #
18 | # Because we fake the 32bit/arm library calls during compile time (the libs are
19 | # loaded during run time) we can build 32bit/arm builds on a 64bit system without needing multi-arch
20 | # GTK libraries (fyi: there aren't any... and DO NOT install the i386 ones, since they will REMOVE what
21 | # you already have - buggering your system!)
22 | #
23 | #
24 | #
25 | # TODO: clean up below, verify arm builds.
26 | # # arm: gcc-arm-linux-gnueabi gcc-4.8-arm-linux-gnueabihf
27 | # hf or no hf? beaglebone, rasbpi, ODROID-U3, other ARM devices
28 | #
29 | # ARMv7sf needs gcc-arm-linux-gnueabi, ARMv7hf needs gcc-arm-linux-gnueabihf
30 | #
31 | # To compile for the ARMv7 (BeagleBone Black), follow:
32 | # http://www.michaelhleonard.com/cross-compile-for-beaglebone-black/
33 | #
34 | # for raspi/BBB
35 | # http://www.michaelhleonard.com/cross-compile-for-beaglebone-black/
36 | # http://derekmolloy.ie/beaglebone/setting-up-eclipse-on-the-beaglebone-for-c-development/
37 | # http://stackoverflow.com/questions/9324772/cross-compiling-static-c-hello-world-for-android-using-arm-linux-gnueabi-gcc?rq=1
38 | #
39 | #
40 | #for ANY OTHER OS/ARCH, the easiest, and most straight forward method is to use
41 | # crosstool-ng. http://crosstool-ng.org/
42 | # howto's:
43 | # http://raspberrypi.stackexchange.com/questions/1/how-do-i-build-a-gcc-4-7-toolchain-for-cross-compiling
44 | # http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/
45 | # http://www.ps3devwiki.com/wiki/Cross_Compiling
46 | #
47 | #
48 | ######################################################################
49 | # as per: http://stackoverflow.com/questions/8937492/what-is-upxs-best-compression-method
50 | # it is NOT a good idea to compress exe's. WHY? Because they run slower, and HDD space is no longer a concern.
51 | # especially since the executable is ~ 500k.
52 | ######################################################################
53 | #
54 | # Copyright 2015 dorkbox, llc
55 | #
56 | # Licensed under the Apache License, Version 2.0 (the "License");
57 | # you may not use this file except in compliance with the License.
58 | # You may obtain a copy of the License at
59 | #
60 | # http://www.apache.org/licenses/LICENSE-2.0
61 | #
62 | # Unless required by applicable law or agreed to in writing, software
63 | # distributed under the License is distributed on an "AS IS" BASIS,
64 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65 | # See the License for the specific language governing permissions and
66 | # limitations under the License.
67 | ######################################################################
68 |
69 | readonly true=1 yes=1 no=0 false=0
70 |
71 |
72 | BUILD_ENV=`uname -s`-`uname -m`
73 |
74 |
75 | if [[ "$BUILD_ENV" != "Linux-x86_64" ]]; then
76 | echo " ********"
77 | echo " ******** Can ONLY build on [[ $BUILD_ENV ]]"
78 | echo " ********"
79 | return false
80 | fi
81 |
82 | echo " ********"
83 | echo " ******** Build Environment: [[ $BUILD_ENV ]]"
84 | echo " ********"
85 |
86 | export PROGRAM_DEPLOY=true
87 |
88 | #############
89 | #core function that will build our targets
90 | #############
91 | build() {
92 | BUILD_TYPE=$1
93 | export COMPILE_OS=$2
94 | export COMPILE_OS_ARCH=$3
95 |
96 | echo " ********"
97 | echo " ******** Building: ${COMPILE_OS}""_""${COMPILE_OS_ARCH}"
98 | echo " ********"
99 |
100 | # compile
101 | make -f $BUILD_TYPE all
102 | }
103 |
104 |
105 | ####################################################################
106 | ####################################################################
107 | ####################################################################
108 | ####################################################################
109 | # DONE WITH FUNCTIONS
110 | ####################################################################
111 | ####################################################################
112 | ####################################################################
113 | BUILD_ALL=false
114 |
115 | if [ -z "$1" ]; then
116 | BUILD_ALL=true
117 | elif [[ "$1" == "all" ]]; then
118 | BUILD_ALL=true
119 | fi
120 |
121 |
122 | # No args will build all.
123 | if [[ $BUILD_ALL == true ]]; then
124 | if [ -z "$1" ]; then
125 | echo " ******** Building linux (32/64), macosx (32/64), windows (32/64)"
126 | echo " ******** Press enter to continue... "
127 | read VARNAME
128 | fi
129 |
130 | # LINUX
131 | build "make_linux.mak" linux 32
132 | build "make_linux.mak" linux 64
133 |
134 |
135 | # WINDOWS
136 | build "make_windows.mak" windows 32
137 | build "make_windows.mak" windows 64
138 |
139 |
140 | # MAC
141 | build "make_macosx.mak" macosx 32
142 | build "make_macosx.mak" macosx 64
143 | else
144 | # LINUX
145 | if [[ "$1" == "linux" ]]; then
146 | echo " ******** Building linux (32/64)"
147 |
148 | build "make_linux.mak" linux 32
149 | build "make_linux.mak" linux 64
150 | elif [[ "$1" == "linux_32" ]]; then
151 | build "make_linux.mak" linux 32
152 | elif [[ "$1" == "linux_64" ]]; then
153 | build "make_linux.mak" linux 64
154 |
155 | # WINDOWS
156 | elif [[ "$1" == "windows" ]]; then
157 | #all
158 | echo " ******** Building windows (32/64)"
159 |
160 | build "make_windows.mak" windows 32
161 | build "make_windows.mak" windows 64
162 |
163 | elif [[ "$1" == "windows_32" ]]; then
164 | build "make_windows.mak" windows 32
165 | elif [[ "$1" == "windows_64" ]]; then
166 | build "make_windows.mak" windows 64
167 |
168 | # MAC
169 | elif [[ "$1" == "macosx" ]]; then
170 | #all
171 | echo " ******** Building macosx (32/64)"
172 |
173 | build "make_macosx.mak" macosx 32
174 | build "make_macosx.mak" macosx 64
175 | elif [[ "$1" == "macosx_32" ]]; then
176 | build "make_macosx.mak" macosx 32
177 | elif [[ "$1" == "macosx_64" ]]; then
178 | build "make_macosx.mak" macosx 64
179 |
180 | else
181 | echo "Please one of the following:"
182 | echo " [all] - builds all of them"
183 | echo ""
184 | echo "linux"
185 | echo " linux [all] - builds 32 and 64 bit linux"
186 | echo " linux_32 [all] - builds 32 bit linux"
187 | echo " linux_64 [all] - builds 64 bit linux"
188 | echo ""
189 | echo "mac"
190 | echo " macosx [all] - builds 32 and 64 bit mac"
191 | echo " macosx_32 [all] - builds 32 bit mac"
192 | echo " macosx_64 [all] - builds 64 bit mac"
193 | echo ""
194 | echo "windows"
195 | echo " windows [all] - builds 32 and 64 bit windows"
196 | echo " windows_32 [all] - builds 32 bit windows"
197 | echo " windows_64 [all] - builds 64 bit windows"
198 | exit 0
199 | fi
200 | fi
201 |
202 |
--------------------------------------------------------------------------------
/make_common.mak:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Makefile for creating the app launcher program.
3 | #
4 | # This + parent makefiles expect the following environment variables set:
5 | #
6 | # COMPILE_OS - linux, macosx, windows
7 | # COMPILE_OS_ARCH - 32, 64, arm
8 | #
9 | ################################################################################
10 | #
11 | # Copyright 2015 dorkbox, llc
12 | #
13 | # Licensed under the Apache License, Version 2.0 (the "License");
14 | # you may not use this file except in compliance with the License.
15 | # You may obtain a copy of the License at
16 | #
17 | # http://www.apache.org/licenses/LICENSE-2.0
18 | #
19 | # Unless required by applicable law or agreed to in writing, software
20 | # distributed under the License is distributed on an "AS IS" BASIS,
21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | # See the License for the specific language governing permissions and
23 | # limitations under the License.
24 | ######################################################################
25 |
26 |
27 | CORE_NAME=libudt-2.3.2
28 | TARGET_PATH=dist
29 | JVM=jvm
30 |
31 |
32 | #setup architecture and path parameters
33 | ifeq ($(COMPILE_OS_ARCH),32)
34 | CCFLAGS +=-DI386
35 | M_ARCH=-m32
36 | DIST_OS_NAME=$(COMPILE_OS)_32
37 | else ifeq ($(COMPILE_OS_ARCH),64)
38 | CCFLAGS +=-DAMD64
39 | M_ARCH=-m64
40 | DIST_OS_NAME=$(COMPILE_OS)_64
41 | else ifeq ($(COMPILE_OS_ARCH),ARM)
42 | #todo finish filling this out
43 | CCFLAGS +=-DARM
44 | endif
45 |
46 |
47 | # mingw doesn't support the M_ARCH flag.
48 | ifeq ($(COMPILE_OS),windows)
49 | M_ARCH =
50 | endif
51 |
52 | CCFLAGS +=${M_ARCH}
53 |
54 | #Makes it small AND FAST
55 | CCFLAGS +=-O2
56 |
57 | ifneq ($(COMPILE_OS),macosx)
58 | CCFLAGS +=-flto
59 | endif
60 |
61 | # warnings and speed/space tricks
62 | FLAGS += \
63 | -P -ftrapv -funroll-loops -fno-strict-aliasing \
64 | -fvisibility=hidden -fvisibility-inlines-hidden -finline-functions \
65 | -Wextra -Wshadow -Wpointer-arith -Wcast-align \
66 | -Wstrict-overflow=5 -Wsign-compare
67 |
68 | ifneq ($(COMPILE_OS),windows)
69 | CCFLAGS +=-fPIC
70 | endif
71 |
72 |
73 | #common path includes
74 | CCFLAGS += \
75 | -Isrc/
76 |
77 | UDT_OBJS = api.o buffer.o cache.o ccc.o channel.o udtCommon.o core.o epoll.o list.o md5.o packet.o queue.o window.o
78 |
79 | $(UDT_OBJS): %.o: src/%.cpp src/%.h src/udt.h
80 | @$(CPP) $(CCFLAGS) $< -c
81 |
82 | lib: $(UDT_OBJS)
83 | @$(CPP) $(CCFLAGS) $(LDFLAGS) -o $(DIST_NAME) $^ $(LIBS)
84 |
85 | udt: lib
86 |
87 | dist-clean: clean
88 | @rm -f *.dll *.so *.dylib
89 |
90 | clean:
91 | @rm -f *.o *.a
92 |
93 |
--------------------------------------------------------------------------------
/make_linux.mak:
--------------------------------------------------------------------------------
1 | #*******************************************************************************
2 | # Makefile for creating the GTK launcher program.
3 | #
4 | # This makefile expects the utility "pkg-config" to be in the PATH.
5 | #
6 | # This makefile expect the following environment variables set:
7 | #
8 | # COMPILE_OS - linux, macosx, windows
9 | # COMPILE_OS_ARCH - 32, 64, arm
10 | #*******************************************************************************
11 | #
12 | # Copyright 2015 dorkbox, llc
13 | #
14 | # Licensed under the Apache License, Version 2.0 (the "License");
15 | # you may not use this file except in compliance with the License.
16 | # You may obtain a copy of the License at
17 | #
18 | # http://www.apache.org/licenses/LICENSE-2.0
19 | #
20 | # Unless required by applicable law or agreed to in writing, software
21 | # distributed under the License is distributed on an "AS IS" BASIS,
22 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | # See the License for the specific language governing permissions and
24 | # limitations under the License.
25 | ######################################################################
26 |
27 |
28 | include make_common.mak
29 |
30 | DIST_NAME=$(CORE_NAME).so
31 | DIST_PATH=linux_$(COMPILE_OS_ARCH)
32 |
33 | CPP=g++
34 | STRIP=strip
35 |
36 | LDFLAGS = -shared
37 | LIBS = -lpthread -ldl -lm
38 |
39 | CCFLAGS += \
40 | -DLINUX \
41 | -isystem/usr/include \
42 | -pthread \
43 |
44 | all: dist-clean udt
45 | @echo "\nDONE WITH COMPILE...."
46 | $(STRIP) --strip-debug --strip-unneeded $(DIST_NAME)
47 | @mkdir -p "$(TARGET_PATH)/$(DIST_OS_NAME)"
48 | mv "$(DIST_NAME)" "$(TARGET_PATH)/$(DIST_OS_NAME)"
49 | @# now cleanup
50 | @$(MAKE) -s -f make_common.mak clean
51 |
52 |
--------------------------------------------------------------------------------
/make_macosx.mak:
--------------------------------------------------------------------------------
1 | #**********************************************************************
2 | # Makefile for creating the Carbon eclipse launcher program.
3 | #
4 | # This makefile expects the following environment variables set:
5 | #
6 | # cross compile libs from : https://launchpad.net/~flosoft/+archive/cross-apple/+packages
7 | #
8 | # This makefile expect the following environment variables set:
9 | #
10 | # COMPILE_OS - linux, macosx, windows
11 | # COMPILE_OS_ARCH - 32, 64, arm
12 | #*******************************************************************************
13 | #
14 | # Copyright 2015 dorkbox, llc
15 | #
16 | # Licensed under the Apache License, Version 2.0 (the "License");
17 | # you may not use this file except in compliance with the License.
18 | # You may obtain a copy of the License at
19 | #
20 | # http://www.apache.org/licenses/LICENSE-2.0
21 | #
22 | # Unless required by applicable law or agreed to in writing, software
23 | # distributed under the License is distributed on an "AS IS" BASIS,
24 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | # See the License for the specific language governing permissions and
26 | # limitations under the License.
27 | ######################################################################
28 |
29 |
30 | include make_common.mak
31 |
32 | DIST_NAME=$(CORE_NAME).dylib
33 | DIST_PATH=macosx_$(COMPILE_OS_ARCH)
34 |
35 | CPP=i686-apple-darwin10-g++
36 | STRIP=i686-apple-darwin10-strip
37 |
38 | LDFLAGS = -shared -dynamiclib -compatibility_version 1.0 -current_version 1.0 -mmacosx-version-min=10.5
39 | LIBS = -lpthread -lm
40 |
41 | #setup architecture parameters
42 | ifeq ($(COMPILE_OS_ARCH),32)
43 | CCFLAGS += -arch i386
44 | else
45 | MACOSX_IS_64BIT=true
46 | CCFLAGS += -arch x86_64
47 | endif
48 |
49 | CCFLAGS += -DMACOSX
50 |
51 | all: dist-clean udt
52 | @echo "\nDONE WITH COMPILE...."
53 | @mkdir -p "$(TARGET_PATH)/$(DIST_OS_NAME)"
54 | mv "$(DIST_NAME)" "$(TARGET_PATH)/$(DIST_OS_NAME)"
55 | @# now cleanup
56 | @$(MAKE) -s -f make_common.mak clean
57 |
58 |
--------------------------------------------------------------------------------
/make_windows.mak:
--------------------------------------------------------------------------------
1 | #*******************************************************************************
2 | # Makefile for creating the launcher program.
3 | #
4 | # This makefile expects the following environment variables set:
5 | #
6 | # Allow for cross-compiling under linux.
7 | # USES mingw-w64 !!!! (NOT mingw32, which is deprecated)
8 | #
9 | #*******************************************************************************
10 | #
11 | # Copyright 2015 dorkbox, llc
12 | #
13 | # Licensed under the Apache License, Version 2.0 (the "License");
14 | # you may not use this file except in compliance with the License.
15 | # You may obtain a copy of the License at
16 | #
17 | # http://www.apache.org/licenses/LICENSE-2.0
18 | #
19 | # Unless required by applicable law or agreed to in writing, software
20 | # distributed under the License is distributed on an "AS IS" BASIS,
21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | # See the License for the specific language governing permissions and
23 | # limitations under the License.
24 | ######################################################################
25 |
26 | include make_common.mak
27 |
28 | DIST_NAME=$(CORE_NAME).dll
29 | DIST_PATH=windows_$(COMPILE_OS_ARCH)
30 |
31 | ifeq ($(COMPILE_OS_ARCH),32)
32 | MINGVER = i686
33 | #mingw flags
34 | CCFLAGS +=-DWINVER=0x0501
35 |
36 | #32 bit support is XP+
37 | CCFLAGS +=-D_WIN32_WINNT=0x0501
38 | else
39 | MINGVER = x86_64
40 | #mingw flags
41 | CCFLAGS +=-DWINVER=0x0600
42 |
43 | #64 bit support is vista+ ONLY
44 | CCFLAGS +=-D_WIN32_WINNT=0x0600
45 | endif
46 |
47 | CPP = $(shell which $(MINGVER)-w64-mingw32-g++)
48 | STRIP = $(shell which $(MINGVER)-w64-mingw32-strip)
49 |
50 |
51 | LDFLAGS = -shared -static -static-libgcc -static-libstdc++ -Wl,--kill-at
52 | LIBS = -lkernel32 -luser32 -lws2_32
53 |
54 | CCFLAGS += \
55 | -isystem/usr/$(MINGVER)-w64-mingw32/include \
56 | -DWINDOWS \
57 |
58 | all: dist-clean udt
59 | @echo "\nDONE WITH COMPILE...."
60 | @# now cleanup
61 | @# now strip the DLL of unneeded, since it can be HUGE
62 | $(STRIP) --strip-debug --strip-unneeded $(DIST_NAME)
63 | @mkdir -p "$(TARGET_PATH)/$(DIST_OS_NAME)"
64 | mv "$(DIST_NAME)" "$(TARGET_PATH)/$(DIST_OS_NAME)"
65 | @$(MAKE) -s -f make_common.mak clean
66 |
67 |
--------------------------------------------------------------------------------
/src/api.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | Copyright (c) 2001 - 2010, The Board of Trustees of the University of Illinois.
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are
7 | met:
8 |
9 | * Redistributions of source code must retain the above
10 | copyright notice, this list of conditions and the
11 | following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce the
14 | above copyright notice, this list of conditions
15 | and the following disclaimer in the documentation
16 | and/or other materials provided with the distribution.
17 |
18 | * Neither the name of the University of Illinois
19 | nor the names of its contributors may be used to
20 | endorse or promote products derived from this
21 | software without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 | *****************************************************************************/
35 |
36 | /*****************************************************************************
37 | written by
38 | Yunhong Gu, last updated 09/28/2010
39 | *****************************************************************************/
40 |
41 | #ifndef __UDT_API_H__
42 | #define __UDT_API_H__
43 |
44 |
45 | #include