Giter VIP home page Giter VIP logo

Comments (26)

m3talsmith avatar m3talsmith commented on May 4, 2024

I'm going to attempt this over the weekend.

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

xD

from swifter.

gabebear avatar gabebear commented on May 4, 2024

IBM's Swift Linux repl thing has a http server/client example(server.swift). http://swiftlang.ng.bluemix.net/#/repl

from swifter.

ankitspd avatar ankitspd commented on May 4, 2024

Foundation for linux is not yet complete so very difficult to port this project to linux
even NSString has so many unimplemented method
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSString.swift

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

hi all,

I spend some time on the support for Linux. I worked on Socket class and it compiles successfully on Linux machine ( Ubuntu 15.10 Swift 2.2 ). I removed:

  1. NSData dependency from HttpServer and Socket classes ( both use [UInt8] array ).
  2. String::dataUsingEncoding(...) dependency from HttpServer and Socket classes.

I am going to continue the journey with the following roadmap:

  1. Remove NSRegularExpression dependency from HttpServer ( maybe together with routing mechanism redesign ).
  2. Remove objc_sync_enter/objc_sync_exit dependency from HttpServer.
  3. Remove NSURL dependency from HttpServer.

Guys, if you have any ideas or pull requests please let me know !

best,
dk

from swifter.

julien-c avatar julien-c commented on May 4, 2024

Awesome!

Why do you need to remove the NSURL dependency? What's missing in the
current implementation in Foundation core libs?

How can we help?!

Julien

On Sunday, December 6, 2015, Damian Kołakowski [email protected]
wrote:

hi all,

I spend some time on the support for Linux. I worked on Socket class and
it compiles successfully on Linux machine ( Ubuntu 15.10 Swift 2.2 ). I
also removed NSData dependency from HttpServer and Socket classes ( both
use [UInt8] array ).

I am going to continue the journey with the following roadmap:

  1. Remove NSRegularExpression dependency from HttpServer ( maybe together
    with routing mechanism redesign ).
  2. Remove objc_sync_enter/objc_sync_exit dependency from HttpServer.
  3. Remove NSURL dependency from HttpServer.

Guys, if you have any ideas or pull requests please let me know !

best,
dk


Reply to this email directly or view it on GitHub
#60 (comment).

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

@julien-c thanks :)

The following classes works on Linux:
Socket.swift, HttpRequest.swift, HttpParser.swift

TODO: HttpServer, HttpResponse.

best,
dk

from swifter.

johnno1962 avatar johnno1962 commented on May 4, 2024

Hi @glock45 if you’re looking for dispatch_async try https://github.com/johnno1962/NSLinux

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

hi @johnno1962

Correct me If I am wrong ? Every time I call dispatch_async the library creates a new thread and after the run all the resources are released ( which is absolutely fine for me ) ?

best
dk

from swifter.

gabebear avatar gabebear commented on May 4, 2024

It does look to spin a thread every time... I'm confused why @johnno1962 code would be better than the dispatch_async provided by Apple/Swift? https://github.com/apple/swift/blob/8d9ef80304d7b36e13619ea50e6e76f3ec9221ba/test/ClangModules/Dispatch_test.swift

I admittedly haven't used swift on Linux yet, but have been using GCD via ObjC on Linux for a long while now. http://chris.mowforth.com/posts/2011/installing-grand-central-dispatch-on-linux/

from swifter.

julien-c avatar julien-c commented on May 4, 2024

I've put in some work on the Linux support of swifter (in #72, #73, #74, #75).

One of the last roadblocks on getting basic support (first of all, getting to something that builds 😄) is the locking that happens in HttpServer. My question is: is it really needed? If it is, is there something equivalent that we could use in Glibc?

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

@julien-c How about something like https://gist.github.com/kristopherjohnson/d12877ee9a901867f59?

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

Really it boils down to just using a NSLock and doing:

nslock.lock()
closure()
nslock.unlock()

from swifter.

julien-c avatar julien-c commented on May 4, 2024

@C0deH4cker Your link seems to 404

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

@julien-c Thanks for a great work !!!!! I pushed two changes more and finally we compile on Linux ( with NSLinux from @johnno1962 ). I have not run it yet xD This tension kills me xD

@C0deH4cker thanks for NSLock ! I've update Swifter. I've been thinking about ( dispatch_semaphore ) since it's more friendly for GCD environment we have.

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

@julien-c Whoops, looks like I accidentally removed the last "9"! Try this one: https://gist.github.com/kristopherjohnson/d12877ee9a901867f599

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

I'll clone it and test on Ubuntu 14.04 now and let you know!

from swifter.

damian-kolakowski avatar damian-kolakowski commented on May 4, 2024

( I build on Linux using "swift build" ).

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

Built both NSLinux.a and Swifter.a. How are you building the samples?

from swifter.

julien-c avatar julien-c commented on May 4, 2024

Yay! Swifter server running on Ubuntu here: http://swift.circular.io:8080/ 🎉🎉

from swifter.

julien-c avatar julien-c commented on May 4, 2024

The app's code is here: https://github.com/julien-c/example-package-dealer

Small variation on Apple's playing card dealer example. There's a pretty sweet /cards endpoint here: http://swift.circular.io:8080/cards

I had to unplug the JSON serialisation as NSJSONSerialization is unimplemented in Foundation so far.

from swifter.

julien-c avatar julien-c commented on May 4, 2024

I've just posted this to Hacker News, if you wish to upvote 😄 https://news.ycombinator.com/item?id=10718544

from swifter.

C0deH4cker avatar C0deH4cker commented on May 4, 2024

Got a demo running on my server as well! Took a little extra time as I didn't realize Azure firewalls new VMs from everything but SSH by default, not using iptables but external to the VM (and it seems that adding a new firewall rule is broken). Great work!

from swifter.

johnno1962 avatar johnno1962 commented on May 4, 2024

congrats @glock45. @gabebear You’re right NSLinux’s dispatch_async is pretty inefficient spinning a thread each call but libdispatch seems not to be available on Linux. It should clean up after each thread exits (calls pthread_detach)

from swifter.

gabebear avatar gabebear commented on May 4, 2024

oops, interesting, I'd setup my ObjC Linux server long enough ago I'd forgotten how I'd done it. Went back and I've been using http://nickhutchinson.me/libdispatch/ (forgot I'd even installed it)

from swifter.

segabor avatar segabor commented on May 4, 2024

Hi,

Happy to see it runs on Linux at last. Here's my work that makes the example run also, with build script.

https://github.com/segabor/swifter/commit/918a751e1ef02cb0c13c72e20512a1465218fcc1
Cheers,

Gábor

from swifter.

Related Issues (20)

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.