Ejemplo n.º 1
0
int
connectToServer(const StaticString &address, const char *file, unsigned int line) {
	TRACE_POINT();
	switch (getSocketAddressType(address)) {
	case SAT_UNIX:
		return connectToUnixServer(parseUnixSocketAddress(address), file, line);
	case SAT_TCP: {
		string host;
		unsigned short port;

		parseTcpSocketAddress(address, host, port);
		return connectToTcpServer(host, port, file, line);
	}
	default:
		throw ArgumentException(string("Unknown address type for '") + address + "'");
	}
}
Ejemplo n.º 2
0
int
createServer(const StaticString &address, unsigned int backlogSize, bool autoDelete) {
	TRACE_POINT();
	switch (getSocketAddressType(address)) {
	case SAT_UNIX:
		return createUnixServer(parseUnixSocketAddress(address),
			backlogSize, autoDelete);
	case SAT_TCP: {
		string host;
		unsigned short port;
		
		parseTcpSocketAddress(address, host, port);
		return createTcpServer(host.c_str(), port, backlogSize);
	}
	default:
		throw ArgumentException(string("Unknown address type for '") + address + "'");
	}
}
Ejemplo n.º 3
0
void
setupNonBlockingSocket(NConnect_State &state, const StaticString &address) {
	TRACE_POINT();
	state.type = getSocketAddressType(address);
	switch (state.type) {
	case SAT_UNIX:
		setupNonBlockingUnixSocket(state.s_unix, parseUnixSocketAddress(address));
		break;
	case SAT_TCP: {
		string host;
		unsigned short port;
		
		parseTcpSocketAddress(address, host, port);
		setupNonBlockingTcpSocket(state.s_tcp, host, port);
		break;
	}
	default:
		throw ArgumentException(string("Unknown address type for '") + address + "'");
	}
}