New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UdpSocket: implement broadcast sending capability #7677

Merged
merged 5 commits into from Jan 22, 2019

Conversation

Projects
None yet
3 participants
@414n
Copy link
Contributor

414n commented Jan 6, 2019

Closes #7676.

This adds a new setBroadcast method to the UdpSocket class that, like the setBlocking, setFastSend ones for the (TCP) Socket class, enables or disables the permission to send to broadcast addresses.
This requires the changes found in HaxeFoundation/neko#191 and HaxeFoundation/hxcpp#756 to properly work.

Alan added some commits Jan 5, 2019

Alan
ADD: Socket.setBroadcast method
This should enable sys.net.Socket instances to send data to broadcast addresses
Alan
FIX: move setBroadcast only inside UdpSocket
Given that in a TCP socket context (which is what the Socket class implements) broadcast messaging is not supported, this should only be implemented in the UdpSocket class.
Alan
@Simn

This comment has been minimized.

Copy link
Member

Simn commented Jan 9, 2019

This fails on cppia:

Command: haxe [compile-cppia-host.hxml]
haxelib run hxcpp Build.xml haxe -Ddebug -Ddll_export="bin/cppia.classes" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.000" -Dhxcpp_api_level="400" -Dhxcpp_smart_strings="1" -Dscriptable="1" -Dsource-header="''" -Dsource_header="''" -Dstatic="1" -Dutf16="1" -I"src/" -I"" -I"/home/travis/build/HaxeFoundation/haxe/std/cpp/_std/" -I"/home/travis/build/HaxeFoundation/haxe/std/"
Compiling group: haxe
g++ -Iinclude -c -fvisibility=hidden -g -fpic -fPIC -Wno-overflow -DHX_LINUX -DHXCPP_DEBUG -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_DLL_EXPORT(haxe) -DHXCPP_SCRIPTABLE(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=400(haxe) -m64 -DHXCPP_M64 -I/home/travis/haxelib/hxcpp/git/include ... tags=[haxe,static]
 - src/sys/ssl/Digest.cpp 
 - src/sys/net/UdpSocket.cpp 
 - src/sys/io/File.cpp 
 - src/sys/net/Address.cpp 
Error: ./src/sys/net/UdpSocket.cpp: In member function ‘virtual void sys::net::UdpSocket_obj::setBroadcast(bool)’:
./src/sys/net/UdpSocket.cpp:150:55: error: ‘_hx_std_socket_set_broadcast’ was not declared in this scope
 HXDLIN(  61)  _hx_std_socket_set_broadcast(this->__s,b);
                                                       ^
Error: Build failed
Command exited with 1 in 2s: haxe [compile-cppia-host.hxml]
@414n

This comment has been minimized.

Copy link
Contributor

414n commented Jan 10, 2019

Hello Simon,

thanks for taking a look.
Yep, it probably fails because it is missing changes from both HaxeFoundation/neko#191 and HaxeFoundation/hxcpp#756 PRs, that introduce the new operation in the neko and hxcpp backends.

Do you mind taking a look at them too?

Alan added some commits Jan 20, 2019

Alan
Alan
@ncannasse

This comment has been minimized.

Copy link
Member

ncannasse commented Jan 21, 2019

Looks good to me

@Simn

This comment has been minimized.

Copy link
Member

Simn commented Jan 21, 2019

This fails on OS X cppia:

Command: haxe [compile-cppia-host.hxml]
haxelib run hxcpp Build.xml haxe -Ddebug -Ddll_export="bin/cppia.classes" -Dhaxe3="1" -Dhaxe4="1" -Dhaxe_ver="4.000" -Dhxcpp_api_level="400" -Dhxcpp_smart_strings="1" -Dscriptable="1" -Dsource-header="''" -Dsource_header="''" -Dstatic="1" -Dutf16="1" -I"src/" -I"" -I"/Users/travis/build/HaxeFoundation/haxe/std/cpp/_std/" -I"/Users/travis/build/HaxeFoundation/haxe/std/"
Compiling group: haxe
g++ -Iinclude -c -fvisibility=hidden -stdlib=libc++ -isysroot /Applications/Xcode-9.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -g -I/Users/travis/haxelib/hxcpp/git/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -Wno-overflow -DHXCPP_DEBUG -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_DLL_EXPORT(haxe) -DHXCPP_SCRIPTABLE(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=400(haxe) ... tags=[haxe,static]
 - src/sys/net/UdpSocket.cpp 
Error: ./src/sys/net/UdpSocket.cpp:150:15: error: use of undeclared identifier '_hx_std_socket_set_broadcast'; did you mean '_hx_std_socket_set_blocking'?
HXDLIN(  61)            _hx_std_socket_set_broadcast(this->__s,b);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        _hx_std_socket_set_blocking
/Users/travis/haxelib/hxcpp/git/include/hx/StdLibs.h:642:36: note: '_hx_std_socket_set_blocking' declared here
HXCPP_EXTERN_CLASS_ATTRIBUTES void _hx_std_socket_set_blocking( Dynamic o, bool b );
                                   ^
1 error generated.
Error: Build failed
Command exited with 1 in 4s: haxe [compile-cppia-host.hxml]

@414n 414n closed this Jan 21, 2019

@414n 414n reopened this Jan 21, 2019

@414n

This comment has been minimized.

Copy link
Contributor

414n commented Jan 21, 2019

@Simn I guess the previous Travis build did not obtain latest sources from the hxcpp repo: by forcing a rebuild, CI seems happy again.

@Simn Simn merged commit 39475bc into HaxeFoundation:development Jan 22, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Simn

This comment has been minimized.

Copy link
Member

Simn commented Jan 22, 2019

Looks like you're right. Thanks a lot for your contribution!

@414n 414n deleted the 414n:socket_broadcast branch Jan 22, 2019

@414n

This comment has been minimized.

Copy link
Contributor

414n commented Jan 22, 2019

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment