1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Reddit AMA with Adam Myhill on Cinemachine, Thurs July 27 - 10AM PT. More info.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  7. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Good ol' Sockets (.NET sockets for mobile without Unity Pro) [Released]

Discussion in 'Assets and Asset Store' started by ZimM, Feb 12, 2014.

  1. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871

    $logo_only.png
    v2.0.0

    Asset Store Link

    This plugin is only useful for Unity 4 free version users. Built-in sockets are already enabled for Unity 4 Pro and Unity 5 users.

    Good ol' Sockets
    is a drop-in substitute for System.Net.Sockets namespace subset. It is designed to make it possible for Unity developers to use sockets on Android and iOS platforms without a Pro license. It also includes an automatic patcher tool that allows to convert popular assets (such as Photon Networking Free, Tasharen Networking, UniWeb and others) in a single click!
    Good ol' Sockets aim to replicate the API of .NET sockets as close as possible. What this means for you is that you can use pretty much any code that uses System.Net.Sockets, including MSDN and hundreds of tutorials over the Web. Two simple commented demo scenes are also included.

    Note: Good Ol' Sockets are slower than native Unity implementation, and do not implement whole System.Net.Sockets and System.Net namespaces. However, this won't affect most applications, as sockets are rarely the bottleneck, and the chosen API subset is sufficient for almost any needs.

    A free evaluation version is available upon request to contact@lostpolygon.com or PM on forums.

    Features:
    • Full support for Unity 4.x - 5.x versions. Android and iOS platforms are supported.
    • Allows to use .NET sockets on Android & iOS without the need for Pro license.
    • Allows to run a lot of popular assets, such as Tasharen Network, Photon Networking Free, UniWeb and many others.
    • Automatic patcher tool that detects and fixes socket usage in scripts and .dll.
    • Easiest possible code porting - just change the namespace and you're done!
    • Replicates the .NET sockets API to the tiniest details.
    Documentation:

    If you like the asset, please review/rate it on the Asset Store, I'll greatly appreciate that :)
     
    Last edited: Mar 3, 2015
    Cogent and JohnTube like this.
  2. Fragmental

    Fragmental

    Joined:
    Jun 30, 2013
    Posts:
    55
    Pretty sweet. This might save me from needing to pay 7500 for licenses. How much of a performance decrease might this create using uniweb?

    Also, any chance of try-before-you-buy?

     
  3. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    $7500? But Pro licenses for iOS+Android is $1500+$1500, isn't it?
    Performance decrease for asset like UniWeb is negligible, I don't think it'd be actually possible to notice any difference.

    Also, check your PM.
     
  4. Fragmental

    Fragmental

    Joined:
    Jun 30, 2013
    Posts:
    55
    I think it would be 1500 for pro, 1500, for android, and 1500 for ios. So that's 4500. Not sure where I got 7500 from. Even with blackberry and team license it's 6500. That might have been what I meant to say.
     
  5. fingersbleeding

    fingersbleeding

    Joined:
    Jun 10, 2013
    Posts:
    23
    Hey ZimM,

    Came across your pluggin on reccomend from the BestHTTP plugin dev. Our team is trying out BestHTTP to replace WWW class, but we don't want to purchase 5+ seats of pro licenses so we can design / QA. Your plugin is exactly what we're looking for.

    BUT:

    When I attempt to run Tools > Lost Polygon > Patch , I get the following error:

    MissingMethodException: Method not found: 'Mono.Cecil.TypeReference.set_Scope'.
    System.Collections.Generic.List`1[Mono.Cecil.TypeReference].ForEach (System.Action`1 action) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:361)
    A.A.A (Mono.Cecil.AssemblyDefinition , System.String , System.String , Mono.Cecil.AssemblyNameReference )
    A.A.A (System.String )
    A.B.A (System.String[] )
    A.c.A ()


    I can see the class Mono.Cecil.dll included in the Editor folder. Come across this before?
     
  6. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Hi there,

    that's weird, I haven't encountered this issue before. Can you please try importing just BestHTTP+Good ol' Sockets in a new project and see if it works then?
     
  7. fingersbleeding

    fingersbleeding

    Joined:
    Jun 10, 2013
    Posts:
    23
    I was able to get it to work in a new project with only BestHTTP and Good Ol' Sockets imported. Brought the updated files back into my project and exported without a hitch. Thanks for the suggestion.
     
  8. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    That bug was probably caused by some conflicting dll's in your project, or maybe Unity was just behaving weird... But anyway, glad you got it working :)
     
  9. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Version 1.1 update is now live at the Asset Store!
    Changelog:
    • Fixed some compatibility issues (make sure to update if you are using Tasharen Network!).
    • Fixed build on Windows Phone platform (build no longer crashes when Good ol' Sockets are in the project).
    • Improved assembly patcher.
     
  10. ZeoWorks

    ZeoWorks

    Joined:
    Dec 13, 2012
    Posts:
    76
    I just purchased this awesome asset, I can't thank you enough for this! :D
     
  11. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Thanks! :) Be sure to ask if you have any questions.
     
  12. dceevp

    dceevp

    Joined:
    Mar 4, 2013
    Posts:
    19
    hi!
    I have a really stupid question :\
    Does this plugin work with standard unity network?
     
  13. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Standard Unity network does not uses .NET sockets, so the question doesn't really applies. Standard networking works on all platforms on free version of Unity.
     
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Version 1.2 update is now live at the Asset Store!
    Changelog:
    • Added an option to revert the namespace patch.
    • Added System.Net.CookieContainer support.
    • Improved demos.
     
  15. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    I have to inform everyone who uses Good ol' Sockets that current version v1.2.3 contains a bug, preventing correct work with Tasharen Network and, probably, some other assets. The fix is already submitted to the Asset Store, but it may take a few days to get approved, so meanwhile, just PM me with your invoice number and I'll send the update to you. Sorry for all the inconvenience.

    - Serhii
     
  16. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Hi everyone,
    the 1.2.4 update is now live on the Asset Store and includes the fix for issues introduced in 1.2.3, and also has added TNet 1.9.6b compatibility.
     
  17. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    10
    On Mac, building the project fails. I followed the instruction in the "known issues" section. But default runtime in monodevelop does not changed.
     
  18. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    What do you mean under "does not changed"? I've just repeated the steps and it works fine. Have you clicked the "Set as Default" button?
     

    Attached Files:

  19. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Oh, just did some googling and it seems like sometimes it doesn't gets applied to the project automatically. In that case, go to Project → Active Runtime and select the Unity runtime from there:
    2014-07-28_16-16-10.png
     
  20. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    10
    When I attempt to build, I get the following error:

    Cross compilation job uLink.dll failed.
    UnityEngine.UnityException: Failed AOT cross compiler: /Applications/Unity/Unity.app/Contents/PlaybackEngines/iOSSupport/Tools/OSX/mono-xcompiler --aot=full,asmonly,nodebug,static,outfile="uLink.dll.s" "uLink.dll" current dir : /Users/jeongsuhong/Downloads/New Unity Project 5/Temp/StagingArea/Data/Managed
    Env: Apple_PubSub_Socket_Render = '/tmp/launch-lqa7tt/Render'
    LOGNAME = 'jeongsuhong'
    __CHECKFIX1436934 = '1'
    MONO_PATH = '/Users/jeongsuhong/Downloads/New Unity Project 5/Temp/StagingArea/Data/Managed'
    MONO_DEBUG = 'explicit-null-checks'
    TMPDIR = '/var/folders/hk/h85pcv911db8vwx3g902n71m0000gn/T/'
    USER = 'jeongsuhong'
    SSH_AUTH_SOCK = '/tmp/launch-qe29cn/Listeners'
    GC_DONT_GC = 'yes please'
    SHELL = '/bin/bash'
    __CF_USER_TEXT_ENCODING = '0x1F5:3:51'
    GAC_PATH = '/Users/jeongsuhong/Downloads/New Unity Project 5/Temp/StagingArea/Data/Managed'
    HOME = '/Users/jeongsuhong'
    PATH = '/usr/bin:/bin:/usr/sbin:/sbin'
    result file exists: True. Timed out: False
    stdout:
    stderr:

    at UnityEditor.MonoProcessUtility.RunMonoProcess (System.Diagnostics.Process process, System.String name, System.String resultingFile) [0x00000] in <filename unknown>:0
    at UnityEditor.MonoCrossCompile.CrossCompileAOT (BuildTarget target, System.String crossCompilerAbsolutePath, System.String assembliesAbsoluteDirectory, CrossCompileOptions crossCompileOptions, System.String input, System.String output, System.String additionalOptions) [0x00000] in <filename unknown>:0
    at UnityEditor.MonoCrossCompile+JobCompileAOT.ThreadPoolCallback (System.Object threadContext) [0x00000] in <filename unknown>:0
    UnityEditor.HostView:OnGUI()
     
  21. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    10
    Yes. I selected the added runtme, but I gets the error message. Anyway, you guys are great and Good ol' sockets is great asset !!
    It works fine with ulink in android, and that is already eonugh for me. Thanks.
     
    Last edited: Jul 29, 2014
  22. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Oh, you haven't mentioned that it is AOT cross compiler that failed. Go to Build Settings… → Player Settings → Other Settings and set “Api Compatibility Level” to “.NET 2.0”. This should fix the AOT compiler crash.
    I'm actually surprised to hear the uLink works for you - last time I've tested it was crashing... Well, probably some of my fixes fixed uLink compatibility too :)
     
  23. wilwilwil

    wilwilwil

    Joined:
    Jul 27, 2012
    Posts:
    10
    Thank you for your quick response.
    Good ol' Sockets works fine with uLink but still fails on iOS build even when I changed the ".Net 2.0" setting.
     
  24. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Ah, I see. That pretty much means that uLink is NOT 100% compatible with Good ol' Sockets, and while some basic features of uLink may work, it can all still break easily. It is not a bad thing if it still works for you, but be warned - uLink is not officially supported at the moment and may not work as expected.
     
  25. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Hi ZimM,

    I just purchased Good 'ol Sockets and saw the documentation say that it is a little slower than using regular sockets. I was curious if GoS was smart enough to use the default sockets on platforms that support them (standalone) and only use your implementation of the sockets on platforms that don't support default sockets (non-Android Pro).

    Thanks for the asset!
     
  26. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Hi there,
    no, GoS isn't doing anything like that, as that will make things waaay more complicated, and it isn't easy to handle sometimes already. But really, you shouldn't be even bothering about that small performance decrease - I was never able to find any evidence that GoS somehow slowed a game down measurably. Also, in case you are working with the source code, you can just do something like:
    Code (csharp):
    1.  
    2. #if UNITY_ANDROID || UNITY_IPHONE
    3. using LostPolygon.System.Net.Sockets;
    4. #else
    5. using System.Net.Sockets;
    6. #endif
    7.  
    Also, you can just revert the patch before building for platforms that do support sockets and patch it back when building for Android/iOS.
     
    Deozaan likes this.
  27. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    The 1.3 update that includes a lot of compatibility fixes (especially with TNet) is submitted to the Asset Store now, but as always, just PM me with your invoice number and I'll send the update to you before it is live on the store (and I really recommend TNet users to do that).
     
  28. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    The 1.3 update is now live at the Asset Store!
    Changelog:
    • added per-directory patching
    • much improved general .NET sockets compatibility
    • improved Tasharen Network compatibility
     
  29. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    Latest version of Good ol Sockets 1.3.0g causes compile errors when targeting the Webplayer platform.

    I had to delete the Demos folder to stop most of the errors, but now I still get an error saying:

    And all the editor menu items have disappeared, so I can't revert to System.Sockets. It seems Unity is having trouble loading the DLLs while the editor is targeting WebPlayer.
     
  30. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Thanks, I've reproduced that too. This is really weird, I'll look into into it as soon as I can.
     
  31. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Seems like System.Net.Configuration and System.Security namespaces are not available at all in Webplayer, which is a problem, since Good ol' Sockets now use that namespace, and there is no way to not use them in a compiled DLL. Actually fixing this could take some time, but I think I'll be able to hack something soon just to make it work on Webplayer.
     
  32. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    OK, just fixed compilation under Webplayer platform and sent the update to the Asset Store for review. Feel free to PM me if you want the update before it is live.

    EDIT: update to 1.3.0h is already live now. This was probably the fastest review I've ever had :)
     
    Last edited: Aug 16, 2014
  33. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    19
  34. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Hi there,
    hm, I haven't encountered this before. I'll investigate the issue and report here when I'll have some kind of solution.
     
  35. tolleybot

    tolleybot

    Joined:
    Jun 28, 2014
    Posts:
    10
    I am having the same issue as Kyubun. I see the posts are a couple of years old. Was this resolved?
     
  36. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    I have no idea why are you seeing these posts as two years old, but this was literally reported yesterday, 17.08.2014. And the asset is less than a year old. In any case, I am investigating the issue and I think I'll have a solution in the nearest days.
     
  37. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    @kyubuns, @tolleybot
    OK, I've fixed the issue and sent the update to the Asset Store for review. It may take some time to get approved, though, so feel free to PM me with your invoice number and I'll send the update to you.
     
  38. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    19
    I got a bug fixed version.
    thank you!
     
  39. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Aaand the 1.3.0k is now live in the Asset Store, everyone go grab the fix if you've encountered this issue with building for iOS.
     
  40. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,397
    When I try to add this with Photon. I get the error:

    Code (csharp):
    1.  
    2. Assets/Editor/PhotonNetwork/AccountService.cs(45,9): error CS0103: The name `ServicePointManager' does not exist in the current context
    3.  
     
  41. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Open AccountService.cs file and add this line in the usings section:
    using ServicePointManager = System.Net.ServicePointManager;
     
    hopeful likes this.
  42. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    519
    I think what happened was that @tolleybot was looking at the "Joined" date under your avatar rather than the "posted" date at the bottom of each post. I do that too, sometimes.
     
  43. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    Ah, makes sense. It is indeed a bit confusing that "Joined" date stands out so much compared to the post date.
     
  44. sippos

    sippos

    Joined:
    Mar 25, 2014
    Posts:
    2
    Hi ZimM,

    I patched the following Dll’s "MySql.Data", "System.Data" and "Mono.Data.Tds".
    When I try to connect to the server I get this error. However it only occurs when I use an IP address ("Server=192.168.1.101"). But when I try to connect to the local host ("Server=localhost") it works fine.

    MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.NullReferenceException: Object reference not set to an instance of an object
    at LostPolygon.System.Net.IPHostEntry.set_AddressList (LostPolygon.System.Net.IPAddress[] value) [0x00000] in <filename unknown>:0
    at MySql.Data.Common.StreamCreator.ParseIPAddress (System.String hostname) [0x00000] in <filename unknown>:0
    at MySql.Data.Common.StreamCreator.GetHostEntry (System.String hostname) [0x00000] in <filename unknown>:0
    at MySql.Data.Common.StreamCreator.GetStream (UInt32 timeout) [0x00000] in <filename unknown>:0
    --- End of inner exception stack trace ---
    at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x00000] in <filename unknown>:0
    at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x00000] in <filename unknown>:0
    UnityEngine.Debug:Log(Object)
    MySQLCS:OnGUI() (at Assets/Scripts/MySQLCS.cs:106)

    Hope you can help me.
     
  45. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    What are these DLL's? Where can I download them? It'd be even better if I'll be able to get their source code.
    I can't guarantee that I'll be able to fix this this, but I'll see what I can do.
     
  46. sippos

    sippos

    Joined:
    Mar 25, 2014
    Posts:
    2
  47. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
  48. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    @sippos
    I've discovered the source of the problem, and I have to state that fixing this in a compiled DLL will really take a lot of time, and I am not even sure it is worth it at the moment, as this change will affect pretty much all other code that uses sockets, potentially leading to more serious bugs. However, the exact issue you've faced would be really easy to fix if you'd accept having to compile it yourself from the source code.
     
  49. alonsoGarrote

    alonsoGarrote

    Joined:
    Jun 23, 2012
    Posts:
    24
    Hi there,
    I want to know if I can use THIS ASSET to connect to a SQLite DB using Android on Unity 4.X.
    Currently, im using Unity 3.5.5(aftwerwards .Net sockets are only a pro feature).
    In my plugins folder im using:
    System.Data.dll
    sqlite3.dll
    Mono.Data.Sqlite.dll
    On Android folder inside, im using: libsqlite3.so
    So, I can connect, ,read, write a SQLite DB, no problems,
    But if I use this on Unity 4.X I got the message: .Net sockets are only supported on Unity Android PRO.

    Will this allow me to connect to SQLite DB on Android?.

    Regards,
    Alonso G.
     
  50. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    871
    The answer is - I have no idea, but maybe. How can I say anything else after being given a list of files? PM me and I'll send you an evaluation version so you can test it yourself.
     
    Cogent likes this.