Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Career in 2005 + n? Pin
Judah Gabriel Himango26-May-05 7:13
sponsorJudah Gabriel Himango26-May-05 7:13 
AnswerRe: Career in 2005 + n? Pin
Anonymous27-May-05 16:31
Anonymous27-May-05 16:31 
QuestionHow to retrieve Image from access Database Pin
eng.mohamed26-May-05 5:55
eng.mohamed26-May-05 5:55 
AnswerRe: How to retrieve Image from access Database Pin
Judah Gabriel Himango26-May-05 9:13
sponsorJudah Gabriel Himango26-May-05 9:13 
GeneralOdbcDataReader!! Pin
trk_wakil26-May-05 5:04
trk_wakil26-May-05 5:04 
GeneralRe: OdbcDataReader!! Pin
pubududilena26-May-05 19:34
pubududilena26-May-05 19:34 
Generalsocket handling Pin
cyrus10926-May-05 4:49
cyrus10926-May-05 4:49 
GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 5:06
S. Senthil Kumar26-May-05 5:06 
Here is a generic Proxy class that forwards connections
class Proxy
	{
		private string appName = "HSMSProxy";
		/// 
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			new Proxy().Start();
		}

		public void Start()
		{
        		TcpListener listener = new TcpListener(5001);
			listener.Start();
			TcpClient activeEntity = listener.AcceptTcpClient();
			TcpClient passiveEntity = new TcpClient("TargetMachine", 5002); // target IP
		        NetworkStream activeStream = activeEntity.GetStream();
			NetworkStream passiveStream = passiveEntity.GetStream();
			new InterStreamWriter(activeStream, passiveStream).Start();
			new InterStreamWriter(passiveStream, activeStream).Start();
			Console.ReadLine();
		}

		private void Log(string message)
		{
			Console.WriteLine(message);
		}
	}

	class InterStreamWriter
	{
		NetworkStream readStream;
		NetworkStream writeStream;

		public InterStreamWriter(NetworkStream readStream, NetworkStream writeStream)
		{
			this.readStream = readStream;
			this.writeStream = writeStream;
		}

		public void Start()
		{
			new System.Threading.Thread(new System.Threading.ThreadStart(ThreadFunc)).Start();
		}

		private void ThreadFunc()
		{
			while (true)
			{
				ArrayList byteList = new ArrayList();

				byte[] myReadBuffer = new byte[1024];
				int numberOfBytesRead = 0;

				do
				{
					numberOfBytesRead = readStream.Read(myReadBuffer, 0, myReadBuffer.Length);  
					for (int i = 0; i<numberOfBytesRead; ++i)
						byteList.Add(myReadBuffer[i]);
				}
				while(readStream.DataAvailable);

				byte[] totalBuffer = (byte[])byteList.ToArray(typeof(byte));
				
				writeStream.Write(totalBuffer, 0, totalBuffer.Length);
				writeStream.Flush();

				byteList.Clear();
			}
		}
	}


Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
GeneralRe: socket handling Pin
cyrus10926-May-05 5:12
cyrus10926-May-05 5:12 
GeneralRe: socket handling Pin
S. Senthil Kumar26-May-05 6:19
S. Senthil Kumar26-May-05 6:19 
GeneralRe: socket handling Pin
cyrus10926-May-05 10:17
cyrus10926-May-05 10:17 
GeneralHandling Win32 logical palette's in C# Pin
Rahsas26-May-05 3:41
Rahsas26-May-05 3:41 
GeneralWord automation selecting tray Pin
Master_Blaster26-May-05 3:05
Master_Blaster26-May-05 3:05 
GeneralRemoting Q. Pin
Member 199247026-May-05 1:06
Member 199247026-May-05 1:06 
GeneralRe: Remoting Q. Pin
S. Senthil Kumar26-May-05 2:59
S. Senthil Kumar26-May-05 2:59 
GeneralRe: Remoting Q. Pin
Member 199247026-May-05 4:42
Member 199247026-May-05 4:42 
GeneralImplementation in C# Pin
Diego12326-May-05 0:52
Diego12326-May-05 0:52 
GeneralRe: Implementation in C# Pin
Marc Clifton26-May-05 1:04
mvaMarc Clifton26-May-05 1:04 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 1:49
Colin Angus Mackay26-May-05 1:49 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 2:55
S. Senthil Kumar26-May-05 2:55 
GeneralRe: Implementation in C# Pin
Colin Angus Mackay26-May-05 3:16
Colin Angus Mackay26-May-05 3:16 
GeneralRe: Implementation in C# Pin
S. Senthil Kumar26-May-05 4:24
S. Senthil Kumar26-May-05 4:24 
GeneralWhy toolbar buttons doesn't care of CausesValidation Pin
Itanium26-May-05 0:38
Itanium26-May-05 0:38 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos26-May-05 5:12
Luis Alonso Ramos26-May-05 5:12 
GeneralRe: Why toolbar buttons doesn't care of CausesValidation Pin
Luis Alonso Ramos26-May-05 5:13
Luis Alonso Ramos26-May-05 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.