예제 #1
0
		protected virtual SocketClient AcceptedSocketClient( SocketServer socketServer, 
			Socket clientSocket, string ipAddress, int port, 
			int sizeOfRawBuffer, object userArg, MessageHandler messageHandler, 
			CloseHandler closeHandler, ErrorHandler errorHandler, ConnectHandler connectHandler)
		{
			return new SocketClient( socketServer, clientSocket,
				ipAddress, port, sizeOfRawBuffer, userArg, messageHandler,
                closeHandler, errorHandler, connectHandler);
		}
예제 #2
0
		/// <summary> Constructor for SocketServer Suppport </summary>
		/// <param name="socketServer"> A Reference to the parent SocketServer </param>
		/// <param name="clientSocket"> The Socket object we are encapsulating </param>
		/// <param name="socketListArray"> The index of the SocketServer Socket List Array </param>
		/// <param name="ipAddress"> The IpAddress of the remote server </param>
		/// <param name="port"> The Port of the remote server </param>
		/// <param name="messageHandler"> Reference to the user defined message handler function </param>
		/// <param name="closeHandler"> Reference to the user defined close handler function </param>
		/// <param name="errorHandler"> Reference to the user defined error handler function </param>
		/// <param name="sizeOfRawBuffer"> The size of the raw buffer </param>
		/// <param name="userArg"> A Reference to the Users arguments </param>
		public SocketClient(SocketServer socketServer, Socket clientSocket, 
			string ipAddress, int port, int sizeOfRawBuffer, 
			object userArg, MessageHandler messageHandler, 	CloseHandler closeHandler, 
			ErrorHandler errorHandler, ConnectHandler connectHandler)
			:this(sizeOfRawBuffer,userArg, messageHandler,closeHandler,errorHandler, connectHandler)
		{

			// Set reference to SocketServer
			this.socketServer = socketServer;

			// Init the socket references
			this.clientSocket    = clientSocket;

			// Set the Ipaddress and Port
			this.ipAddress = ipAddress;
			this.port = port;

			// Init the NetworkStream reference
			this.networkStream = new NetworkStream(this.clientSocket);

			// Set these socket options
			this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, 
				System.Net.Sockets.SocketOptionName.ReceiveBuffer, this.receiveBufferSize);
			this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, 
				System.Net.Sockets.SocketOptionName.SendBuffer, this.sendBufferSize);
			this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, 
				System.Net.Sockets.SocketOptionName.DontLinger, 1);
			this.clientSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Tcp,    
				System.Net.Sockets.SocketOptionName.NoDelay, 1);
			
			// Wait for a message
			Receive();
		}