Thread + socket = (shared) problem? (2.048)

Masahiro Nakagawa repeatedly at gmail.com
Tue Sep 7 02:34:50 PDT 2010


On Tue, 07 Sep 2010 17:51:53 +0900, Bane  
<branimir.milosavljevic at gmail.com> wrote:

> This will throw exception on trying to create socket in derived thread.  
> Socket created in main thread is ok. Is it some shared issue or... ? I  
> have been trying to find something info in docs and mailing list but no  
> result.
>
> import std.stdio;
> import core.thread;
> import std.socket;
>
> class MyThread : Thread {
>   Socket sock;
>   this(){
>     super(&run);
>   }
>   void run(){
>     writeln("thread start");
>     sock = new TcpSocket; // this will throw exception on 2.047, 2.048
>     writeln("thread end");
>   }
> }
>
> void main(){
>   writeln("main start");
>   auto s = new TcpSocket;
>   writeln("socket in main thread created");
>   auto t = new MyThread;
>   t.start;
>   writeln("main end");
> }

Please show your environment. Windows?

On my Mac, No problem.


More information about the Digitalmars-d mailing list