The OpenD Programming Language

FiberManager.connectUnix

Convenience functions that forward to connectStream for the given protocol. They connect, send, and receive in an async manner, but do not create their own fibers - you must already be in one when you call this function.

More...
class FiberManager
version(Posix)
final
connectUnix
(
string path
)

Detailed Description

Connections only work if you are already in a fiber. This is the case in a connectionHandler, but not from your main function. You'll have to make your own worker fiber. (But tbh if you only have one connection anyway, you might as well use a standard Socket.)

If you are already in a connection handler set in the listen family of functions, you're all set - those are automatically in fibers. If you are in main though, you need to make a worker fiber.

Making a worker fiber is simple enough. You can do it with new Fiber or with FiberManager.makeFiber (the latter just calls the former with a size argument set up in the FiberManager constructor).

auto fm = new FiberManager();
fm.makeFiber(() {
	auto socket = fm.connectTcp4(...);

	socket.send(...);
}).call(); // you must call it the first time yourself so it self-registers

OR

import core.thread.fiber;

auto fiber = new Fiber(() {
	auto socket = fm.connectTcp4(...);
	// do stuff in here
}).call(); // same deal, still need to call it the first time yourself to give it a chance to self-register

Meta