Git Product home page Git Product logo

dart-sync-socket's Introduction

Dart Sync Socket

Build Status pub package

A Dart VM Native Extension and supporting Dart libraries that provide synchronous socket and HTTP client support.

Installing

Add the following to your pubspec.yaml:

  sync_socket: '^1.0.1'

Then run 'pub get'.

After getting the package with pub, you will need to build the native extension itself.

To build the shared library on Mac OSX or Linux, run the 'tool/build.sh' script.

To build the DLL on Windows (32 bits):

  • Create a new project of type Win32/Win32 project in Visual Studio 2010 Express.
  • Give the project the name sync_socket.
  • On the next screen of the wizard, change the application type to DLL and select “Empty project”, then choose Finish.
  • Add the "sync_socket_extension.cc" file to the source files folder in the project.
  • Change the following settings in the project’s properties:
    • Configuration properties / Linker / Enable Incremental Linking: Set to NO.
    • Configuration properties / Linker / Input / Additional dependencies: Add dart-sdk\bin\dart.lib, from the downloaded Dart SDK.
    • Configuration properties / Linker / Input / Additional dependencies: Add Ws2_32.lib.lib. This is the Winsock library.
    • Configuration properties / C/C++ / General / Additional Include Directories: Add the path to the directory containing dart_api.h, which is dart-sdk/include in the downloaded Dart SDK.
    • Configuration properties / C/C++ / Preprocessor / Preprocessor Definitions: Add DART_SHARED_LIB. This is just to export the _init function from the DLL, since it has been declared as DART_EXPORT.
  • Build the project with "Release" target, and copy the DLL to the directory "lib".

Testing

Follow the instructions above for building the shared library then run tests as normal.

dart-sync-socket's People

Contributors

cbracken avatar dramos07 avatar drmarcii avatar goderbauer avatar raphaeladam-wf avatar sestegra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart-sync-socket's Issues

Building on Mac OS X / buildscript

Hi,
when building on Mac OSX it is important to set the cpu architecture to the one of the dart binary. Right now, the default download for Dart on Mac OSX is 32bit, but the default architecture when compiling a library on Mac OSX is 64 bit.

Also, could you create a build script for the OSS world for this library?
Here is something that works for me:

#!/bin/bash
set -e

cd $(dirname $0)
SCRIPT_DIR=$(pwd)
DART_BIN=$(which dart)
DART_SDK_DIR=$(dirname $DART_BIN)/..
PLATFORM="$(uname -s)"
DART_VERSION=$(dart --version 2>&1)
case "$DART_VERSION" in
  (*32*)
    DART_ARCH="i386"
    ;;
  (*64*)
    DART_ARCH="x86_64"
    ;;
  (*)
    echo Unsupported dart architecture $DART_VERSION.  Exiting ... >&2
    exit 3
    ;;
esac

# see https://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/
cd $SCRIPT_DIR/dart-sync-socket
pub install
cd lib/src
echo Building dart-sync-socket for platform $PLATFORM/$DART_ARCH
case "$PLATFORM" in
  (Darwin)
    g++ -fPIC -I $DART_SDK_DIR/include -c sync_socket_extension.cc -arch $DART_ARCH
    gcc -shared -Wl,-install_name,libsync_socket_extension.dylib,-undefined,dynamic_lookup,-arch,$DART_ARCH -o \
      ../libsync_socket_extension.dylib sync_socket_extension.o
    ;;
  (Linux)
    g++ -fPIC -I $DART_SDK_DIR/include -c sync_socket_extension.cc -arch $DART_ARCH
    gcc -shared -Wl,-soname,libsync_socket_extension.so,-arch,$DART_ARCH -o \
      ../libsync_socket_extension.so sync_socket_extension.o
    ;;
  (*)
    echo Unsupported platform $PLATFORM.  Exiting ... >&2
    exit 3
    ;;
esac

Library path resolution issue on WIndows

After upgrading to Dart VM 1.1.1 and compiling the new DLL, I can't load dart-sync-scoket anymore.

C:\Data\repos\dart-sync-socket>..\..\Tools\dart\dart-sdk\bin\dart.exe test\test_sync_socket.dart
Unhandled exception:
Unsupported operation: Illegal character in path}
#0      Uri._checkWindowsPathReservedCharacters.<anonymous closure> (dart:core/uri.dart:395)
#1      ListIterable.forEach (dart:_collection-dev/iterable.dart:39)
#2      Uri._checkWindowsPathReservedCharacters (dart:core/uri.dart:390)
#3      Uri._toWindowsFilePath (dart:core/uri.dart:1018)
#4      Uri.toFilePath (dart:core/uri.dart:992)
#5      _filePathFromUri (dart:builtin:249)
'package:sync_socket/sync_socket.dart': error: line 23 pos 1: library handler failed
import 'dart-ext:sync_socket_extension';
^
'file:///C:/Data/repos/dart-sync-socket/test/test_sync_socket.dart': error: line
 21 pos 1: library handler failed
import 'package:sync_socket/sync_socket.dart';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.