C#的Socket简单实现消息发送(5)

public void ReceiveCallback(IAsyncResult ar)
        {
            socketInfo = ar.AsyncState as SocketInfo;
            if (this.OnReceiveMsg != null) OnReceiveMsg();
        }

public void ConnectedCallback(IAsyncResult ar)
        {
            Socket socket = ar.AsyncState as Socket;
            if (socket.Connected)
            {
                if (this.OnConnected != null) OnConnected();
            }
            else
            {
                if (this.OnFaildConnect != null) OnFaildConnect();
            }
        }

public void SendMsg(string msg)
        {
            byte[] buffer = Encoding.ASCII.GetBytes(msg);
            _socket.Send(buffer);
        }

public class SocketInfo
        {
            public Socket socket = null;
            public byte[] buffer = null;

public SocketInfo()
            {
                buffer = new byte[1024 * 4];
            }
        }
    }

public class SocketClientManager

C#的Socket简单实现消息发送

具体源码(.net4.5,vs2013)下载

------------------------------------------分割线------------------------------------------

免费下载地址在

用户名与密码都是

具体下载目录在 /2015年资料/1月/29日/C#的Socket简单实现消息发送/

下载方法见

------------------------------------------分割线------------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5809beea953f3fd694a92b3b07fb7cb3.html