|
-
Jan 31st, 2006, 11:17 PM
#1
Thread Starter
Hyperactive Member
Problem with Streams
Code:
public static void Main()
{
Test p = new Test();
p.Server = "211.143.183.66";
p.Port = 1080;
p.Type = 5;
p.UserID = "anonymous";
try
{
Socket mySocket;
if ((mySocket = Connect(p.Server, p.Port)) != null)
{
NetworkStream myNetworkStream = new NetworkStream(mySocket);
if (myNetworkStream.CanWrite == true)
{
StreamWriter myStreamWriter = new StreamWriter(myNetworkStream);
DataBuffer myDataBuffer = new DataBuffer();
if (p.Type == 4)
{
myDataBuffer.InsertByte(4);
myDataBuffer.InsertByte(1);
myDataBuffer.InsertInt16(IPAddress.HostToNetworkOrder(p.Port));
myDataBuffer.InsertInt32(Convert.ToInt32(IPAddress.Parse(p.Server)));
myDataBuffer.InsertCString(p.UserID);
}
else if (p.Type == 5)
{
myDataBuffer.InsertByte(5);
myDataBuffer.InsertByte(2);
myDataBuffer.InsertByte(0);
myDataBuffer.InsertByte(2);
}
myDataBuffer.WriteToOutputStream(myStreamWriter);
if (myNetworkStream.CanRead == true)
{
StreamReader myStreamReader = new StreamReader(myNetworkStream);
DataReader myDataReader = new DataReader(myStreamReader);
}
}
else if (myNetworkStream.CanWrite == false)
{
Console.WriteLine("Network Stream is Not Writeable!");
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.ReadLine();
}
I get errors whenever i seem to reference my Stream Reader/Writer to one of my other classes
These are the errors i get:
Argument '1': cannot convert from 'System.IO.StreamReader' to 'System.IO.Stream'
Argument '1': cannot convert from 'System.IO.StreamWriter' to 'System.IO.Stream'
The best overloaded method match for 'Proxy.GUI.Console.DataBuffer.WriteToOutputStream(System.IO.Stream)' has some invalid arguments
The best overloaded method match for 'Proxy.GUI.Console.DataReader.DataReader(System.IO.Stream)' has some invalid arguments
Thank You For The Help
- Joel
Last edited by BaDDBLooD; Feb 1st, 2006 at 06:26 PM.
-
Jan 31st, 2006, 11:26 PM
#2
Re: Problem with Streams
That' because the StreamReader and StreamWriter classes are not derived from the Stream class. They read from and write to streams but they are not streams themselves. They each have a BaseStream property that is a Stream object.
-
Jan 31st, 2006, 11:29 PM
#3
Re: Problem with Streams
You got in before I edited my previous post. Take another look.
-
Jan 31st, 2006, 11:32 PM
#4
Thread Starter
Hyperactive Member
Re: Problem with Streams
 Originally Posted by jmcilhinney
That' because the StreamReader and StreamWriter classes are not derived from the Stream class. They read from and write to streams but they are not streams themselves. They each have a BaseStream property that is a Stream object.
You are like a programming god, thank you so much!
-
Feb 1st, 2006, 12:10 AM
#5
Re: Problem with Streams
 Originally Posted by BaDDBLooD
You are like a programming god, thank you so much!
More like a programming buffoon in really nice clothes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|