Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Socket±à³Ì(C#)

//Socket»ù±¾±à³Ì
//·þÎñ¶Ë£º
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
Thread mythread ;
Socket socket;
// ÇåÀíËùÓÐÕýÔÚʹÓõÄ×ÊÔ´¡£
protected override void Dispose( bool disposing )
{
try
¡¡ { ¡¡¡¡
¡¡¡¡ socket.Close();//ÊÍ·Å×ÊÔ´
¡¡¡¡ mythread.Abort ( ) ;//ÖÐÖ¹Ïß³Ì
¡¡ }
¡¡ catch{ }
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public static IPAddress GetServerIP()
{
IPHostEntry ieh=Dns.GetHostByName(Dns.GetHostName());
return ieh.AddressList[0];
}
private void BeginListen()
{
IPAddress ServerIp=GetServerIP();
IPEndPoint iep=new IPEndPoint(ServerIp,8000);
socket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
byte[] byteMessage=new byte[100];
this.label1.Text=iep.ToString();
socket.Bind(iep);
// do
while(true)
{
try
{
socket.Listen(5);
Socket newSocket=socket.Accept();
newSocket.Receive(byteMessage);
string sTime = DateTime.Now.ToShortTimeString ( ) ;
string msg=sTime+":"+"Message from:";
msg+=newSocket.RemoteEndPoint.ToString()+Encoding.Default.GetString(byteMessage);
this.listBox1.Items.Add(msg);
}
catch(SocketException ex)
{
this.label1.Text+=ex.ToString();
}
}
// while(byteMessage!=null);
}
//¿ªÊ¼¼àÌý
private void button1_Click(object sender, System.EventArgs e)
{
try
{
mythread = new Thread(new ThreadStart(BeginListen));
mythread.Start();
}
catch(System.Exception er)
{
MessageBox.Show(er.Message,"Íê³É",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
}
//¿Í»§¶Ë£º
using System.Net;
using System.Net.Sockets;
using System.Text;
private void button1_Click(object sender, System.EventArgs e)
{
BeginSend();
}
private void BeginSend()
{
string ip=this.txtip.Text;
string port=this.txtport.Text;
IPAddress serverIp=IPAddress.Parse(ip);
int serverPort=Convert.ToInt32(port);
IPEndPoint iep


Ïà¹ØÎĵµ£º

C#ÀàºÍC#½á¹¹ÌåµÄ¹Øϵ

C#ÀࣺÀàÊÇC# Öй¦ÄÜ×îΪǿ´óµÄÊý¾ÝÀàÐÍ£¬ÀàÒ²¶¨ÒåÁËÊý¾ÝÀàÐ͵ÄÊý¾ÝºÍÐÐΪ¡£È»ºó£¬³ÌÐòÔ±¿ÉÒÔ´´½¨×÷Ϊ´ËÀàµÄʵÀýµÄ¶ÔÏó¡£
C#½á¹¹Ì壺½á¹¹ÌåÊÇÇáÁ¿Ð͵ÄÀ࣬ʹÓÿªÏúÏà¶ÔÓÚÀà½ÏС¡£
C#ÀàºÍC#½á¹¹ÌåÁ½ÕߵĹØϵ£º
1.Êý¾ÝÀàÐÍ£ºÀàºÍ½á¹¹Ì嶼ÊÇÊý¾ÝÀàÐÍ£¬ÀàÊÇÒýÓÃÀàÐÍ£¬½á¹¹ÌåÊÇÖµÀàÐÍ¡£
2.¼Ì³ÐÐÔ£ºÀà¿ÉÒԼ̳кͱ»¼Ì³Ð£¬¶ø½á¹ ......

C# ¹Ø¼ü×ÖexternÓ÷¨

ÐÞÊηûÓÃÓÚÉùÃ÷ÔÚÍⲿʵÏֵķ½·¨¡£extern ÐÞÊηûµÄ³£¼ûÓ÷¨ÊÇÔÚʹÓà Interop ·þÎñµ÷Èë·Ç
ÍйܴúÂëʱÓë DllImport ÊôÐÔÒ»ÆðʹÓã»ÔÚÕâÖÖÇé¿öÏ£¬¸Ã·½·¨»¹±ØÐëÉùÃ÷Ϊ static£¬ÈçÏÂÃæµÄʾÀýËùʾ£º[DllImport("avifil32.dll")]
private static extern void AVIFileInit();
×¢Òâ
extern ¹Ø¼ü×Ö»¹¿ÉÒÔ¶¨ÒåÍⲿ³ÌÐò¼¯±ðÃû£¬Ê¹ ......

C#ÃæÊÔ±ÊÊÔСÌùÊ¿ 1

ü   ref¡¢out¡¢Óëparams
Ó¦¸ÃÀ´ËµÕâÈý¸ö¹Ø¼üÔÚÒ»°ãµÄ±àÂë¹ý³ÌÖл¹Êǻ᲻ʱÉæ¼°µ½µÄ£¬ËùÒÔ²»Ëãʲô“ÀäƧ”µÄ¸ÅÄî¡£ÓйØÈý¸ö²ÎÊýÐÞÊηûµÄ½âÊÍÈçÏ£º
Ref£ºref¹Ø¼ü×ÖÈÃÒ»¸öÖµÀàÐ͵ÄÊäÈë²ÎÊý°´ÒýÓô«µÝ¡£Êµ¼ÊÉÏ£¬¶ÔÓÚÒýÓÃÀàÐ͵IJÎÊý£¬ÊÇ·ñʹÓÃref¹Ø¼ü×Ö£¬²î±ð΢ºõÆä΢¡£ÓÐÒ»¸öÀýÍâÊÇStringÀàÐ͵IJΠ......

C#ͳ¼Æ¿á¹·²¥·ÅÁбíÀï¸èÇú²¥·ÅµÄ×Üʱ¼ä

ÊÖ»úÒôÀÖ²¥·¢Æ÷ÀïÓÐ×ÜÎļþ×Üʱ¼äµÄͳ¼Æ£¬ÔÚ¿á¹·²¥·ÅÆ÷ÀïÕÒÁËÒ»ÏÂûÕÒµ½¡£ÄÇÎÒÏëÖªµÀÕâЩ¸èÇúµÄ×Üʱ¼ä£¬¸ÃÔõô°ì£¿
ÆäʵºÜ¼òµ¥£¬ÉÔÉÔ¶¯¶¯ÊÖ£¬¾ÍÄÜÕÒµ½´ð°¸£¡
Çë²Î¿¼Èçϲ½Ö裺
µÚÒ»²½£¬±£´æ²¥·ÅÁÐ±í£¬°ÑÀïÃæµÄ¸èÇú±£´æµ½Ò»¸öÄãϲ»¶µÄÃû×Ö¡£
µÚ¶þ²½£¬ÔÚ²¥·ÅÁбíÉÏÃæµãÓÒ¼ü£¬µ½´¦²¥·ÅÁÐ±íµ½ÄãÕҵĵ½µÄµØ·½¡£
¾­²âÊÔ£¬×îР......

C# aspx Êý¾Ý°ó¶¨·½·¨¼¯

Eval("")ºÍBind("")¡¡ÕâÁ½ÖÖÒ»¸öµ¥Ïò°ó¶¨£¬Ò»¸öË«Ïò°ó¶¨£¬bindÊÇË«Ïò°ó¶¨,µ«ÐèÊý¾ÝÔ´Ö§³Ö
ASP.NET   2.0¸ÄÉÆÁËÄ£°åÖеÄÊý¾Ý°ó¶¨²Ù×÷£¬°Ñv1.xÖеÄÊý¾Ý°ó¶¨Óï·¨DataBinder.Eval(Container.DataItem,   fieldname)¼ò»¯ÎªEval(fieldname)¡£Eval·½·¨ÓëDataBinder.EvalÒ»Ñù¿ÉÒÔ½ÓÊÜÒ»¸ö¿ÉÑ¡µÄ¸ñʽ»¯×Ö·û´®²Î ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ