public static PooledSocket CreateNewSocket(string host, int port, SocketPool pool, BinaryFormatter formatter) { try { var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(host, port); return(new PooledSocket(socket, pool, formatter)); } catch { return(null); } }
private PooledSocket(Socket socket, SocketPool pool, BinaryFormatter formatter) { this.formatter = formatter; messageStream = new MemoryStream(); this.socket = socket; writeLock = new object(); this.pool = pool; socket.SendTimeout = 1000; //1 seconds :| is it okie? socket.NoDelay = true; socket.DontFragment = true; socket.LingerState.Enabled = false; ReadBuffer(4, HEADER); }
public static PooledSocket CreateNewSocket(Socket socket, SocketPool pool, BinaryFormatter formatter) { return(new PooledSocket(socket, pool, formatter)); }