Closed txdv closed 13 years ago
In what way "disconnect manually"? Closing a socket, but keeping the Socket object in usable state does not make much sense.
Well, so I have to close it and create a new one then, right?
Could you explain, why it doesn't?
I don't think i fully understand your question. If you close a socket, it's closed. Gone. Useless. No matter by what means it was closed. What do you even mean by "disconnect manually"?
something like System.Net.Sockets.Socket::Disconnect(bool reuseSocket)
Ah, now I understand. No, there is currently no way to do that, and I don't think one will be added. The classes in Manos.IO are not intended to be very smart - one socket, one underlying kernel object. You could derive Manos.IO.Socket and emulate the reusable thing, of course.
Another question:
HttpServer takes Context and a Socket into it's constructor. Isn't it kinda redundant? When I think of wrapping an IrcConnection with these manos sockets, I would use only the Context so I could use it to recreate sockets on reconnect and stuff like that.
One could pass a listening port instead, that's correct. Perhaps that'll change in later versions. As for your second question, yes.
I'm writing a Socks4Socket class now, it would be possible to easily use it in HttpServer if the class actually would have a socket in their constructor.
But this leads to another problem, it is not possible to recreate a stream class only with an instance of an stream, which will be useful for socks5, or other prefixed packets.
You mean a wrapper stream? Of course that's possible, there's just no class that does it yet. Or am I misunderstanding?
Not by deriving, but by using an instance of another socket or stream.
I don't understand the problem you are having. If you want a stream that proxies calls to an (interchangeable) base stream, create one.
When I derive from Stream, I have to override WriteByteBuffer, I don't know how I am supposed to do that with just the instance of another Stream
namespace Manos.Awesomeness
{
public class ProxyStream : Stream
{
public Stream Stream { get; set; }
public ProxyStream(Stream stream)
{
Stream = stream;
}
public override void Close()
{
Stream.Close();
}
public override TimeSpan WriteTimeout {
get {
return Stream.WriteTimeout;
}
set {
Stream.WriteTimeout = value;
}
}
// Some other methods
protected int WriteSingleBuffer(ByteBuffer buffer)
{
}
}
Throw some exception. Everything public should be forwarded to the underlying stream, everything nonpublic will then never be called.
Is there a way to disconnect a Socket manually? I am porting smartirc4net to manos and I see that Close() disposes the socket alltogether.