Last active
March 17, 2016 17:36
-
-
Save lukasz-pyrzyk/a0bce458ce1926f6969a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using System.Net.Sockets; | |
namespace XGain.Sockets | |
{ | |
internal class XGainSocket : ISocket | |
{ | |
public int BufferSize => 65535; | |
public bool Connected => _socket.Connected; | |
public Socket InternalSocket => _socket; | |
public EndPoint LocalEndPoint => _socket.LocalEndPoint; | |
public EndPoint RemoteEndPoint => _socket.RemoteEndPoint; | |
private readonly Socket _socket; | |
public XGainSocket( | |
AddressFamily addressFamily, | |
SocketType socketType = SocketType.Stream, | |
ProtocolType protocolType = ProtocolType.Tcp, | |
bool noDelay = true, | |
int? buffer = null) | |
{ | |
_socket = new Socket(addressFamily, socketType, protocolType) | |
{ | |
SendBufferSize = buffer ?? BufferSize, | |
ReceiveBufferSize = buffer ?? BufferSize, | |
NoDelay = noDelay | |
}; | |
} | |
public XGainSocket(Socket socket) | |
{ | |
_socket = socket; | |
} | |
public ISocket Accept() | |
{ | |
Socket client = _socket.Accept(); | |
return new XGainSocket(client); | |
} | |
public void Bind(IPEndPoint localEndPoint) | |
{ | |
_socket.Bind(localEndPoint); | |
} | |
public void Connect(IPEndPoint remoteEndPoint) | |
{ | |
_socket.Connect(remoteEndPoint); | |
} | |
[...] | |
public void Dispose() | |
{ | |
_socket.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment