gsocketbase.cs

来自「语音视频功能 里面实现了基本的QQ与语音对话」· CS 代码 · 共 75 行

CS
75
字号
using System;
using System.Net;
using System.Net.Sockets;
namespace gowk.net.Sockets
{
	/// <summary>
	/// IGSocket 的摘要说明。
	/// </summary>
	public abstract class GSocketBase:ISocket
	{
		protected Socket OwnerSock;
		private Proxy m_Proxy;

		public virtual int Send(byte[] buffer)
		{
			return this.OwnerSock.Send(buffer);
		}
		public virtual int SendTo(byte[] buffer, EndPoint remoteEP)
		{
			return this.OwnerSock.SendTo(buffer,remoteEP);
		}
		
		public virtual int Receive(byte[] buffer)
		{
			return this.OwnerSock.Receive(buffer);
		}
		public virtual int ReceiveFrom(byte[] buffer, ref EndPoint remoteEP)
		{
			return this.OwnerSock.ReceiveFrom(buffer,ref remoteEP);
		}

		public virtual void Close()
		{
			this.OwnerSock.Close();
		}
		public abstract void Connect(string host,int port);
		public virtual object GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName)
		{
			return this.OwnerSock.GetSocketOption(optionLevel,optionName);
		}
		public virtual void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
		{
			this.OwnerSock.SetSocketOption(optionLevel,optionName,optionValue);
		}
		public virtual void Bind(EndPoint ep)
		{
			this.OwnerSock.Bind(ep);
		}
		public virtual Proxy Proxy
		{
			get{return m_Proxy;}
			set{this.m_Proxy=value;}
		}
		public virtual void LoginProxy()
		{
		}
		public virtual void Negotiation(string host,int port)
		{
		}
		public void AsyncInvoke(AsyncCallback callback)
		{
			callback.BeginInvoke(null,null,null);
		}
		public virtual System.IO.Stream GetStream()
		{
			return new NetworkStream(this.OwnerSock);
		}
		public virtual bool Connected
		{
			get{return (this.OwnerSock!=null)&&this.OwnerSock.Connected;}
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?