Hey. This was a requested tutorial. Nothing special really.
He wanted it to be called "educational source". See attached.
He wanted it to be called "educational source". See attached.
public DotNetSocket(ushort port)
{
_connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_connection.Bind(new IPEndPoint(IPAddress.Any, port));
}
public void Connect(IAsyncResult result)
{
Wrapper _w = new Wrapper();
_w.Socket = _connection;
_connection.Accept();
ClientConnect.Invoke(_w);
Not quite. Read the comments that I put in there. You don't want to set the server's socket to the client's personal socket.Quote:
Here's one void.
Just wanted to share. Got bored and made that small code.Code:public DotNetSocket(ushort port) { _connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _connection.Bind(new IPEndPoint(IPAddress.Any, port)); }
#edit
Im bored, yes.
And i'm learning too! I've never really worked with socket classes, just used pre-made ones.
Fang,
I assume this is right for the start of the Connect void?
?Code:public void Connect(IAsyncResult result) { Wrapper _w = new Wrapper(); _w.Socket = _connection; _connection.Accept(); ClientConnect.Invoke(_w);
Wrapper _w = new Wrapper();
_w.Socket = _connection.EndAccept(result);
_w.Socket.BeginAccept(Connect, new AsyncCallback(Receive));
ClientConnect.Invoke(_w);
Good job. =p You might want to put some checks on that to make sure that the client's socket isn't null.Quote:
Sorry was half asleep at 1am :)
I took one look and done it
most of that function.Code:Wrapper _w = new Wrapper(); _w.Socket = _connection.EndAccept(result); _w.Socket.BeginAccept(Connect, new AsyncCallback(Receive)); ClientConnect.Invoke(_w);