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

Bane branimir.milosavljevic at gmail.com
Tue Sep 7 01:51:53 PDT 2010


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");
}


More information about the Digitalmars-d mailing list