function channel = serverBind(hostName, portNum)
import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;

soRcvBuffSize	= 1024*1024*2;		%2 MByte
soSndBuffSize	= 1024*1024*2;
	try
		%==================================================
		% Configure the server and bind it to a port.
		%==================================================
		isa		= InetSocketAddress(hostName,portNum);
		channel = ServerSocketChannel.open();
		sock	= channel.socket();
		sock.setReceiveBufferSize(soRcvBuffSize);
		sock.setReuseAddress(true);
		channel.configureBlocking(false);
		sock.bind(isa);
	
	catch
		s	= lasterror;

		try
			channel.close();
		catch
			%do nothing
		end

		rethrow(s);
	end
end

Sable
github-repos/MATLAB/Sable-mcbench-benchmarks/mcbench-benchmarks-ba13b2f0296ef49491b95e3f984c7c41fccdb6d8/35608-matsock/serverBind.m
mcbench-benchmarks
github-repos/MATLAB/Sable-mcbench-benchmarks
ba13b2f0296ef49491b95e3f984c7c41fccdb6d8