Hot Search : Source embeded web remote control p2p game More...
Location : Home Search - INT 1
Search - INT 1 - List
/** * 动态数组的模板类 * 1.支持字符索引 * 2.方便的添加删除修改任意一项 * 最后更新 2004-8-9 yzh **1.优化了字符索引的运作方式,使用数组存储 **2.重写了底层数据的存储,将连续性的存储方式改为了非连续, *** 从而很好有效地支持了“引用”,并且让数据的删除增加变的更为快速 * 用法如: * YCArray<int,int> test * test.Add(\"Number2\",4) * test.Add(\"Number1\",2) * printf(\"%d %d\",test[\"Number1\"],test[\"Number2\"]) * 显示: * 2 4 ******* ******* History: 2004-11-19 修改了析构函数,解决了索引没有释放的bug **/-/ ** * dynamic array template class * 1. Support characters Index * 2. Add convenience to delete arbitrary * a final update 2004-8-9 yzh ** 1. Character Index optimized mode of operation, the use of storage arrays ** 2 . a rewrite of the underlying data storage, storage continuity conversion of non-continuous, and thus good *** effective support to the "quote", and let the data changed to delete the more rapid * usage such as : * YCArraylt; int, intgt; test * test. Add ( "Number2", 4) * test.Add ( "Number1", 2) * printf ( "% d% d", test [ "Number1"] test [ "Number2"]) * Display : * * 2 4 ****** ******* History : 2004-11-19 revised the destructors, the index did not address the release of bug ** /
Date : 2008-10-13 Size : 4.98kb User : 叶振华

 

 

 

  一、建立空窗体

  新建一个工程,添加引用,并导入名称空间。

  加入一个设备对象变量:

private Microsoft.DirectX.Direct3D.Device device = null;

  添加初始化图形函数,并在这里面对设备对象进行实例化:

public void InitializeGraphics()
{
 PresentParameters presentParams = new PresentParameters();
 presentParams.Windowed = true;
 presentParams.SwapEffect = SwapEffect.Flip;
 presentParams.AutoDepthStencilFormat = DepthFormat.D16;
 presentParams.EnableAutoDepthStencil = true;
 device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this,  CreateFlags.HardwareVertexProcessing, presentParams);
}

  当程序执行时,需要绘制场景,代码在这个函数里:

public void Render()

{
 // 清空设备,并准备显示下一帧。
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black , 1.0f, 0);
 // 设置照相机的位置
 SetupCamera();
 //开始场景
 device.BeginScene();
 if(meshLoaded)
 {
  mesh.Render(meshLoc);
 }
 device.EndScene();
 //显示设备内容。
 device.Present();
}

  设置照相机的位置:

private void SetupCamera()
{
 device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 1000.00f);
 device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f ,0.0f, 20.0f), new Vector3(0.0f,0.0f, 0.0f), new Vector3(0,1,0));
}

  现在改变主函数,调用我们写的初始化函数,并显示场景:

[STAThread]

static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.Show();

  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
}

  运行程序,会显示一个空的窗体。

  二、加入地球:

  在这一步里需创建一个3D网格对象,来作为要显示的地球,为此,在工程中新加入一个类Earth,此类可以包含所创建的网格对象的信息。

  加入一些相关变量,含义见注释:

public class Earth : BaseEarth
{
 private Material[] mMaterials; //保存材质
 private Texture[] mTextures; //保存纹理
 private Matrix locationOffset; //用来保存网格对象的相对位置
 private Mesh mMesh = null; //三角形网格对象
 private Device meshDevice; //需要显示在哪个设备上。
}

  在构造函数中,把Device设备拷贝到私有成员变量,这样就可以在这个类的其它方法内使用它,另外就是把位置变量进行赋值:

public Earth(ref Device device, Matrix location): base(ref device)
{
 meshDevice = device;
 locationOffset = location;
}

  下面这个函数是装入.X文件。

public bool LoadMesh(string meshfile)
{
 ExtendedMaterial[] mtrl;
 try
 {
  // 装载文件
  mMesh = Mesh.FromFile(meshfile, MeshFlags.Managed, meshDevice, out mtrl);
  // 如果有材质的话,装入它们
  if ((mtrl != null) && (mtrl.Length > 0))
  {
   mMaterials = new Material[mtrl.Length];
   mTextures = new Texture[mtrl.Length];

   // 得到材质和纹理

   for (int i = 0; i < mtrl.Length; i++)
   {
    mMaterials[i] = mtrl[i].Material3D;
    if ((mtrl[i].TextureFilename != null) && (mtrl[i].TextureFilename != string.Empty))

 

    {
     //前面得到的纹理的路径是相对路径,需要保存的是绝对路径,通过应用程序路径可以获得
     mTextures[i] = TextureLoader.FromFile(meshDevice, @"..\..\" + mtrl[i].TextureFilename);
    }
   }
  }
  return true;
 }
 catch
 {
  return false;
 }
}

  在这个方法内,使用Mesh.FromFile()这个方法,从给定的文件名中找到.X文件,并装入相关数据,一旦数据格式设置完成,可以从此文件中找到材质和贴图信息,并把它存放在数组中,并通过文件路径,得到纹理文件文件的路径,最后返回真值,如果整个过程出现错误,返回假值。

  下面这个Render()方法,是把此对象,即地球显示在设备对象上,此方法较简单,通过变形操作来得到网格对象的X,Y,Z坐标,接着设置网格对象的材质和纹理,最后,将每个材质和纹理应用到每个网格。

public void Render(Matrix worldTransform)
{
 /把位置变为世界坐标
 meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 for (int i = 0; i < mMaterials.Length; i++)
 {
  meshDevice.Material = mMaterials[i];
  meshDevice.SetTexture(0, mTextures[i]);
  mMesh.DrawSubset(i);
 }
}

  现在回到窗体代码中,添加引用网格对象的相关变量:

private Earth mesh = null;
private Matrix meshLoc;
private bool meshLoaded = false;

  在图形初始化函数中,需要对网格对象进行初始化。加入下面的代码:

meshLoc = Matrix.Identity;
meshLoc.M41 = 2.0f;
mesh = new Earth(ref device, meshLoc);
if (mesh.LoadMesh(@"..\..\earth.x"))
{
 meshLoaded = true;
}

  代码第一句把网格对象的位置定为原点,接着偏移X轴2个单位,接下来从文件中得到此.X文件。如果成功设置,meshLoaded置为真。注意,这里有一个.X文件,在源代码中有此文件。

 


  在设置相机的函数中,加入一盏灯光:

device.Lights[0].Type = LightType.Directional;
device.Lights[0].Diffuse = Color.White;
device.Lights[0].Direction = new Vector3(0, -1, -1);
device.Lights[0].Update();
device.Lights[0].Enabled = true;


  此灯光较简单,仅为一个直射型白光灯。

最后,在Render()方法中,调用网格对象的Render()方法,以显示地球。

 

  三、使地球旋转

  前面用一个网格对象来建立地球,但此类没有平移,旋转及缩放等方法,下面就加入这些方法,因为这些方法具有通用性,因此可以新建一个类,把这些方法写在这些类中,使地球对象成为它的派生类。

  在工程中新添加一个类:BaseEarth;

  加入进行平移、旋转、缩放的变量:

 

private float xloc = 0.0f;
private float yloc = 0.0f;
private float zloc = 0.0f;
private float xrot = 0.0f;
private float yrot = 0.0f;
private float zrot = 0.0f;
private float xscale = 1.0f;
private float yscale = 1.0f;
private float zscale = 1.0f;


  加入相应的属性代码:

 

public float XLoc
{
 get
 {
  return xloc;
 }
 set
 {
  xloc = value;
 }
}
…………

 

  在Render()虚函数中,应用平移、旋转及缩放。
 

public virtual void Render()
{
 objdevice.MultiplyTransform(TransformType.World,Matrix.Translation(xloc, yloc, zloc));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(1.0f, 0.0f, 0.0f), xrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 1.0f, 0.0f), yrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 0.0f, 1.0f), zrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.Scaling(xscale, yscale, zscale));
 return;
}

 

  现在回到地球类,需要将其改为新类的派生类,同时更改构造函数,另外,在Render()方法中,应先调用基类的Render()方法:


public override void Render()
{
 base.Render();
 //把位置变为世界坐标
 // meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 。。。。。。
}

 


  现在,由于在基类中可以设置对象位置,因此,可以把与locationOffset相关,即与设置位置的变量及语句注释掉。

  四、加入月球

  在这一步加入月球,实际上是再创建一个网格对象新实例,只是把纹理进行更改即可,为了代码模块性更好,把两个对象放在一个新类CModel中,在工程中新添加一个类CModel,并声明对象实例。


public class cModel
{
 private cMeshObject mesh1 = null;
 private cMeshObject mesh2 = null;
 private bool modelloaded;
}


  把窗口代码中的Load()事件,放在CModel中,这次不仅生成了地球,而且生成了月球。

 


public void Load(ref Device device)
{
 mesh1 = new Earth(ref device);
 mesh2 = new Earth(ref device);
 if (mesh1.LoadMesh(@"..\..\earth2.x"))
 {
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
 if (mesh2.LoadMesh(@"..\..\moon.x"))
 {
  mesh2.XLoc += 20.0f;
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
}

 

  下面的Update()方法中,参数dir 用来判断是顺时针旋转还是逆时针旋转,另外,地球和月球绕Y轴增加的角度大小不同,也就决定了二者旋转的速度不同。


public void Update(int dir)
{
 if(dir > 0)
 {
  mesh1.YRot += 0.02f;
  mesh2.YRot += 0.05f;
 }
 else if(dir < 0)
 {
  mesh1.YRot -= 0.02f;
  mesh2.YRot -= 0.05f;
 }
}


  在下面的render()方法中,生成显示月球和地球:

 


public void Render(ref Device device)
{
 device.Transform.World = Matrix.Identity;
 if(modelloaded)
 {
  mesh1.Render();
  mesh2.Render();
 }
}


  把窗口代码中的加入灯光的方法,也放在此类中:


public void LoadLights(ref Device device)
{
 device.Lights[0].Type = LightType.Directional;
 device.Lights[0].Diffuse = Color.White;
 device.Lights[0].Position = new Vector3(0.0f, 0.0f, 25.0f);
 device.Lights[0].Direction = new Vector3(0, 0, -1);
}
public void Light(ref Device device)
{
 device.Lights[0].Update();
 device.Lights[0].Enabled = true;
}


  五、与鼠标交互操作

  为了实现与键盘、鼠标交互,新添加一个类:CMouse,添加引用Microsoft.DirectX.DirectInput,并添加命名空间。加入相关变量:


private Microsoft.DirectX.DirectInput.Device mouse = null;
public System.Threading.AutoResetEvent MouseUpdated;
private float x, y, z = 0.0f;
private byte[] buttons;

 

  在下面的构造函数代码中,首先创建鼠标设备,并初始化回调事件:


public CMouse(System.Windows.Forms.Control control)
{
 mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
 mouse.SetCooperativeLevel(control, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
 mouse.Properties.AxisModeAbsolute = false;
 MouseUpdated = new System.Threading.AutoResetEvent(false);
 mouse.SetEventNotification(MouseUpdated);
 mouse.Acquire();
 Update();

 


  下面的Update()方法中获得鼠标的坐标值,并赋给私有成员变量:

public void Update()
{
 MouseState state = mouse.CurrentMouseState;
 x = state.X;
 y = state.Y;
 z = state.Z;
 buttons = state.GetMouseButtons();
}


  还需要有一个函数来检测鼠标左键是否按下:

 


public bool LeftButtonDown
{
 get
 {
  bool a;
  return a = (buttons[0] != 0);
 }
}


  六、大结局

  现在已经做完了准备工作,返回到窗口代码中,需要对这里的代码重新进行一些调整:

  在图形初始化函数中创建一个CModel类及CMouse类:

 

private CModel model = null;
private CMouse mouse = null;
private bool leftbuttondown = false;
private float mousexloc;

 

  添加对鼠标初始化的方法:

 

网管联盟bitsCN@com


public void InitializeInput()
{
 mouse = new CMouse(this);
}


  添加UpdateInputState()方法,当按下鼠标左键时,将leftbuttondown值设置为真,当鼠标抬起时,将mousexloc置0:


private void UpdateInputState()
{
 mouse.Update();
 if (mouse.LeftButtonDown)
 {
  if(leftbuttondown == false)
  {
   mousexloc = 0.0f;
   leftbuttondown = true;
  }
  else
  {
   mousexloc = -mouse.X;
  }
 }
 else
 {
  leftbuttondown = false;
  mousexloc = 0.0f;
 }
}


  在此程序中,只对X值进行了操作,即只能左右转。

  Render()方法更新如下:

public void Render()
{
 UpdateInputState();
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkGray, 1.0f, 0);
 SetupCamera();
 device.BeginScene();
 model.Update((int)mousexloc);
 model.Light(ref device);
 model.Render(ref device);
 device.EndScene();
 device.Present();
}

 

  最后更改Main()主函数:


static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.InitializeInput();
  EarthForm.Show();
  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
 }
 


Date : 2008-12-12 Size : 11.54kb User : mantoutou

一个判断远程主机存活程序代码(ping) #include #include #include #include #include "winsock.h" #pragma comment(lib,"Ws2_32"); #define SEND_SIZE 32 #define PACKET_SIZE 4096 #define ICMP_ECHO 8 #define ICMP_ECHOREPLY 0 struct icmp { unsigned char icmp_type; unsigned char icmp_code; unsigned short icmp_cksum; unsigned short icmp_id; unsigned short icmp_seq; unsigned long icmp_data; }; struct ip { unsigned char ip_hl:4; unsigned char ip_v:4; unsigned char ip_tos; unsigned short ip_len; unsigned short ip_id; unsigned short ip_off; unsigned char ip_ttl; unsigned char ip_p; unsigned short ip_sum; unsigned long ip_src; unsigned long ip_dst; }; unsigned char sendpacket[PACKET_SIZE]; unsigned char recvpacket[PACKET_SIZE]; struct sockaddr_in dest_addr; struct sockaddr_in from_addr; int sockfd; int pid; unsigned short cal_chksum(unsigned short *addr,int len); int pack(int pack_no); int unpack(unsigned char *buf,int len); void send_packet(void); void recv_packet(void); void main(int argc,char *argv[]) { struct hostent *host; struct protoent *protocol; WSADATA wsaData; int timeout=1000; int SEND_COUNT=4; int i; char *par_host; par_host=argv[argc-1]; //IP赋值 switch(argc) { case 2: break; case 3: if(strcmp(argv[1],"-t")==0) { SEND_COUNT=10000; break; } //fall through default: printf("usage: %s [-t] Host name or IP address\n",argv[0]); exit(1); } if(WSAStartup(0x1010,&wsaData)!=0) { printf("wsastartup error\n"); exit(1); } if( (protocol=getprotobyname("icmp") )==NULL) { printf("getprotobyname error\n"); exit(1); } /* printf("%s\n",protocol->p_name); printf("%s\n",protocol->p_aliases); printf("%d\n",protocol->p_proto); system("pause"); */ if( (sockfd=socket(AF_INET,SOCK_RAW,protocol->p_proto) )<0) { printf("socket error\n"); exit(1); } if(setsockopt(sockfd,SOL_SOCKET,SO_RCVTIMEO,(char*)&timeout,sizeof(timeout))h_length); //resolve address to hostname if(host=gethostbyaddr(host->h_addr,4,PF_INET)) par_host=host->h_name; // //printf("%s\n",par_host); // } else if( dest_addr.sin_addr.s_addr=inet_addr(par_host)==INADDR_NONE) { printf("Unkown host %s\n",par_host); exit(1); } pid=getpid(); /* printf("%d\n",pid); system("pause"); */ printf("Pinging %s [%s]: with %d bytes of data:\n\n",par_host,inet_ntoa(dest_addr.sin_addr),SEND_SIZE); for(i=0;i1) { sum+=*w++; nleft-=2; } if( nleft==1) { *(unsigned char *)(&answer)=*(unsigned char *)w; sum+=answer; } sum=(sum>>16)+(sum&0xffff); sum+=(sum>>16); answer=~sum; return answer; } //打包 int pack(int pack_no) { int packsize; struct icmp *icmp; packsize=8+SEND_SIZE; icmp=(struct icmp*)sendpacket; icmp->icmp_type=ICMP_ECHO; icmp->icmp_code=0; icmp->icmp_cksum=0; icmp->icmp_seq=pack_no; icmp->icmp_id=pid; icmp->icmp_data=GetTickCount(); icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); /*校验算法*/ return packsize; } //解包 int unpack(unsigned char *buf,int len) { struct ip *ip; struct icmp *icmp; double rtt; int iphdrlen; ip=(struct ip *)buf; iphdrlen=ip->ip_hl*4; icmp=(struct icmp *)(buf+iphdrlen); if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) ) { len=len-iphdrlen-8; rtt=GetTickCount()-icmp->icmp_data; printf("Reply from %s: bytes=%d time=%.0fms TTL=%d icmp_seq=%u\n", inet_ntoa(from_addr.sin_addr), len, rtt, ip->ip_ttl, icmp->icmp_seq); return 1; } return 0; } //发送 void send_packet() { int packetsize; static int pack_no=0; packetsize=pack(pack_no++); if( sendto(sockfd,(char *)sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )=0) success=unpack(recvpacket,n); else if (WSAGetLastError() == WSAETIMEDOUT) { printf("Request timed out.\n"); return; } }while(!success); } UID5380 帖子239 精华0 积分1289 阅读权限40 来自软件学院 在线时间81 小时 注册时间2006-5-22 最后登录2007-2-24 查看详细资料 TOP
Date : 2009-05-29 Size : 5.74kb User : shuiyuan313

软件测试:一个编译器测试软件,支持下列C语言运算符:+ - * / % ^(乘方) 负 (int) (double) "字符串" [](数组) > < == >= <= != && ! ++ -- = += -= *= /= %= ^=,支持下列关键字:void int double string if else for while do goto break continue return,支持下列数据类型:int double string int[] double[] string[],支持下列系统函数:int max(int,int),double max(double,double),int[] newint(int),double[] newdouble(int),string[] newstring(int),void delete(int[]),void delete(double[]),void delete(string[]),支持任意用户定义函数,支持函数重载。不支持全局变量。如果发现错误,请告诉我-software testing : a compiler test software to support the following C language Operators :-* /% ^ (involution) negative (int) (double), "string" [] (arrays) gt; Lt; == Gt; = Lt; =! =!---=*= = =/=% = ^ =, to support the following keywords : void int double string if else for while do goto break continue return, to support the following types of data : int double string double int [] [ ] string [], support the following functions : int max (int, int), double max (double, double), newint int [] (int), double newdouble [] (int), newstring string [] (int), void delete (int []), void delete (double []), void delete (string []), support arbitrary user-defined functions, support function overloading. Not to support global variables. If mistakes are found, please tell me
Date : 2026-01-06 Size : 9kb User : 王东

/** * 动态数组的模板类 * 1.支持字符索引 * 2.方便的添加删除修改任意一项 * 最后更新 2004-8-9 yzh **1.优化了字符索引的运作方式,使用数组存储 **2.重写了底层数据的存储,将连续性的存储方式改为了非连续, *** 从而很好有效地支持了“引用”,并且让数据的删除增加变的更为快速 * 用法如: * YCArray<int,int> test * test.Add("Number2",4) * test.Add("Number1",2) * printf("%d %d",test["Number1"],test["Number2"]) * 显示: * 2 4 ******* ******* History: 2004-11-19 修改了析构函数,解决了索引没有释放的bug **/-/*** dynamic array template class* 1. Support characters Index* 2. Add convenience to delete arbitrary* a final update 2004-8-9 yzh** 1. Character Index optimized mode of operation, the use of storage arrays** 2 . a rewrite of the underlying data storage, storage continuity conversion of non-continuous, and thus good*** effective support to the "quote", and let the data changed to delete the more rapid* usage such as :* YCArraylt; int, intgt; test* test. Add ( "Number2", 4)* test.Add ( "Number1", 2)* printf ( "% d% d", test [ "Number1"] test [ "Number2"])* Display :** 2 4************* History : 2004-11-19 revised the destructors, the index did not address the release of bug** /
Date : 2026-01-06 Size : 5kb User : 叶振华

LinCAN is a Linux kernel module that implements a CAN driver capable of working with multiple cards, even with different chips and IO methods. Each communication object can be accessed from multiple applications concurrently. It supports RT-Linux, 2.2, 2.4, and 2.6 with fully implemented select, poll, fasync, O_NONBLOCK, and O_SYNC semantics and multithreaded read/write capabilities. It works with the common Intel i82527, Philips 82c200, and Philips SJA1000 (in standard and PeliCAN mode) CAN controllers. LinCAN project is part of a set of CAN/CANopen related components developed as part of OCERA framework. -LinCAN is a Linux kernel module that implem ents a CAN driver capable of working with multip le cards, even with different chips and IO methods. Each c ommunication object can be accessed from multi ple applications concurrently. It supports RT- Linux, 2.2, 2.4, and 2.6 with fully implemented select, poll, fasync, O_NONBLOCK. and O_SYNC semantics and multithreaded read/w rite capabilities. It works with the common Int el i82527, Philips 82c200. Philips SJA1000 (in standard and PeliCAN mo de) CAN controllers. LinCAN project is part of a set of CAN/Application of CANopen related components develop ed as part of OCERA framework.
Date : 2026-01-06 Size : 846kb User : 李刚

此程序可以将你输入的int类型的IP地址,即addr中保存的IP转换成点分二进制类型的IP,并显示出来。在调试的时候比较有用,写这个也是在调试的时候看看IP是否是正确的。可以把这个小程序加入vs 2005的tool菜单下,使用起来更方便。-This process can put you entered int type of IP address, that is stored in addr into dotted IP binary types of IP, and displayed. In more useful when debugging, writing this is also a time when debugging to see whether the IP is correct. This small program can join the vs 2005 under the tool menu, more user-friendly.
Date : 2026-01-06 Size : 1.07mb User : 陈伟科

跨平台int 64位 整数封装类,测试环境vc6 gcc win2003 -Cross-platform package int 64-bit integer type, test environment vc6 gcc win2003
Date : 2026-01-06 Size : 169kb User : 保密

PHP编写的用户登录 注册程序 通过MYSQL数据验证 密码修改等功能-Requirements - MySQL 3.x or later - PHP 4+ with GD Library - Apache Server - Linux How to Install 1. First create a mysql database (say phplogin) for a particular user name (say guest) and password ( say guest). Then give all previleges of database to the user. 2. Copy the following SQL to create a table and structure CREATE TABLE `users` ( `id` int(20) NOT NULL auto_increment, `full_name` varchar(200) collate latin1_general_ci NOT NULL default , `user_name` varchar(200) collate latin1_general_ci NOT NULL default , `user_pwd` varchar(200) collate latin1_general_ci NOT NULL default , `user_email` varchar(200) collate latin1_general_ci NOT NULL default , `activation_code` int(10) NOT NULL default 0 , `joined` date NOT NULL default 0000-00-00 , `country` varchar(100) collate latin1_general_ci NOT NULL default , `user_activated` int(1) NOT NULL default 0 , PRIMARY KEY (`id`) ) 3. Open dbc.php to edit mysql database name, user name and password.
Date : 2026-01-06 Size : 18kb User : issuoow

局域网上点对点聊天,较为简单,可以当作网络课程的小作业-chating point to point int local arial network,it is simple in some way,you can regard it as homework
Date : 2026-01-06 Size : 31kb User : 张飞

服务器端口监听,实现端口的实时监听-#include <winsock2.h> #include <stdio.h> #include <stdlib.h> int TCount = 0 //MAX Thread numbers int ThreadNumber = 0 //Realtime thread numbers WORD PORT = 139 //PORT to scan HANDLE ThreadEvent HANDLE FinishEvent BOOL FastMode = FALSE char startaddr[ 32 ] char endaddr[ 32 ] //----------------------------------------------------------------------------- // Name: SaveRecord // Desc: Log the useful informations //----------------------------------------------------------------------------- void SaveRecord( LPSTR fmt, ... ) { char buff[ 256 ] wvsprintf( buff, fmt, (LPSTR)(&fmt+1)
Date : 2026-01-06 Size : 3kb User : 姬序龙

/*模式训练*/ Training(int,int,int,char*,char*,char*) 参数: 模式个数(即网络的第一隐层节点数) 模式维数(即网络的输入层节点数) 模式类别数(即网络的输出层节点数) 计算中心控制矢量时所用的变换函数核 第二隐层权值的训练算法 训练模式所在的文件名称 /*模式分类*/ Classifying(int,char*) 参数: 需要分类的模式个数 分类数据-/* Model Training*/Training (int, int, int, char*, char*, char*) parameters: model number (ie, the first hidden layer the network nodes) model dimension (ie number of nodes in the network' s input layer ) mode, the number of categories (ie, number of nodes in the network' s output layer) control vector computing center used by the nuclear transfer function weights the second hidden layer training algorithm training mode where the file name /* classification*/Classifying (int, char* ) parameters: the need for disaggregated data on the number of classification models
Date : 2026-01-06 Size : 619kb User : LiuKe

1. 架构说明 目前的协议有如下一些特点: 1) 客户向服务器发送请求, 每个请求的长度不定. 请求的长度在第一个INT中指定. 2) 每个服务器通常会向多种客户提供服务, 例如, TS要同时向CP, NP提供服务, CP要向NP和其他CP提供服务, 同时还是其他CP, TS, SP的客户. 3) 每个服务器为客户服务时, 通常是长期的, 会涉及多次请求-应答的来回. 这样的结构, 主要是为了能够支持大量并发客户连接而设计的. 在具有大量并发客户 连接时, 无论采用线程还是进程, 都无法进行有效的服务, 因此必须采用select 轮询方式. 2. 基本数据结构说明 对于每个客户端, 需要保存该客户端相应的一些信息. 目前的CPnew.c, SPnew.c 和TSnew.c的核心数据结构基本相同, 都由Session, SessionCluster (TSnew.c中) 或者 ServerDesc (CPnew.c和SPnew.c)构成. 其中, Session是每个客户端相关的数据, SessionCluster(或者是ServerDesc)是 有关每种服务的信息, 其中有一个指向该服务相关的各个Session的指针. Session 这一数据结构不是在有客户请求时动态分配的, 而是在最开始初始化时就已经分配 好的, 当有新客户请求到来时, 服务器搜索这一预先分配好的这些Session, 发现其中 有空闲则使用, 如果没有空闲就报告错误.-1. Architecture Description The current agreement has the following features: 1) The client sends a request to the server, each request the length of the variable. The length of the request specified in the first INT. 2) each server would usually offer a variety of services, such as, TS to the same time to the CP, NP to provide services CP and CP to the NP to provide services, or other CP, TS, SP customers. 3) customer service for each server, usually long-term, will involve multiple requests- response back and forth. Such a structure, mainly to be able to support large numbers of concurrent client connections and design. In a large number of concurrent clients Connection, regardless of the thread or process can not effectively service, so must select Polling. 2. The basic data structure that For each client, the corresponding need to save the client some information. The current CPnew.c, SPnew.c And TSnew.c the core data structure is basically the same, by the Session,
Date : 2026-01-06 Size : 3.27mb User : 风行者

#include <iostream> //包含输入输出流头文件 using namespace std //使用标准命名空间 int main()-# Include <iostream>// Contains the input and output stream header file using namespace std // using the standard namespace int main ()
Date : 2026-01-06 Size : 489kb User : tabuiy

请编写一个面向无连接的基本SOCKET套接字的C/S通信程序。本题属于其服务器端,程序的要求是:创建一个数据报式套接字,并与本地的20005号端口进行绑定,等待客户端发来的一个int数据,收到数据后,将这个int整数输出,并判断它是否为一个素数(判断结果用0和1表示,0表示“否”, 1表示“是”),然后将判断结果回送给对方,最后关闭套接字,退出系统。-Please write a basic connectionless-oriented socket SOCKET C/S communication program. The problem is the server side, the program' s requirements are: to create a datagram type socket, and with the local bind port 20005, waiting for the client sent an int data, receive data, this int integer output, and determine whether it is a prime number (with 0 and 1 to determine the results indicated that 0 means " no" , a " yes" ), and then judge the outcome back to the other side, the last socket is closed, exit the system.
Date : 2026-01-06 Size : 1.71mb User : jjj

VB UDP进行数据传送,是字节数据等等包括BOOL,BTYE,INT,SINGLE-VB UDP data transmission is byte data, etc., including BOOL, BTYE, INT, SINGLE
Date : 2026-01-06 Size : 13kb User : 彭玉江

实现一个简易的printf函数,系统调用write的调用格式为size_t write (int fd,const void * buf,size_t count),将读取buf中字长为count的数据进入到文件描述符为fd的文件中-Achieve a simple printf function, call the system call write format size_t write (int fd, const void* buf, size_t count), will read the word length of buf count data into the file descriptor fd file
Date : 2026-01-06 Size : 1kb User : 黄辉

or (int i = 0 i < len && partCount <= 6 i++) { char ch = Char.Parse(ipData.Substring(i,1)) if (Char.IsDigit(ch)) buf+=ch else if (ch != , ) { throw new IOException("Malformed PASV strReply: " + strReply) } if (ch == , || i+1 == len) { try { parts[partCount++] = Int32.Parse(buf) buf="" } catch (Exception) { throw new IOException("Malformed PASV strReply: " + strReply) -or (int i = 0 i < len && partCount <= 6 i++) { char ch = Char.Parse(ipData.Substring(i,1)) if (Char.IsDigit(ch)) buf+=ch else if (ch != , ) { throw new IOException("Malformed PASV strReply: "+ strReply) } if (ch == , || i+1 == len) { try { parts[partCount++] = Int32.Parse(buf) buf="" } catch (Exception) { throw new IOException("Malformed PASV strReply: "+ strReply)
Date : 2026-01-06 Size : 7.68mb User : mark

包含smac.tcl脚本文件,有delay.awk,energy.awk,throughput.awk文件。还有大量的Shell脚本,从而避免重复性操作。有一份说明文档,给了详尽的说明,包括Tcl运行,执行,获得数据,分析数据,用gnuplot画图等。-include smac.tcl delay.awk energy.awk, throughput.awk.Also exists a lot of shell script, to avoid a lot of repetitive actions. A instruction which show how to do that run tcl, get data, analysis data, and get graphy by gnuplot int details.
Date : 2026-01-06 Size : 36kb User : china

Tcp_client 源代码 SOCKET sclient socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) if(sclient INVALID_SOCKET) { printf( invalid socket ! ) return } CEdit* pEdit (CEdit*)GetDlgItem(IDC_EDIT_PORT) CString sPort pEdit->GetWindowTextW(sPort) //获取端口字符串 int dPort _ttoi(sPort) //获取端口整形 DWORD dwIP m_IP.GetAddress(dwIP) //获取ip sockaddr_in serAddr serAddr.sin_family AF_INET serAddr.sin_port htons(dPort) serAddr.sin_addr.S_un.S_addr htonl(dwIP) //创建连接 if (connect(sclient, (sockaddr *)&serAddr, sizeof(serAddr)) SOCKET_ERROR) { closesocket(sclient) AfxMessageBox(_T( connect error ! )) printf( connect error ! ) return }-Tcp_client SOCKET sclient socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) if(sclient INVALID_SOCKET) { printf( invalid socket ! ) return } CEdit* pEdit (CEdit*)GetDlgItem(IDC_EDIT_PORT) CString sPort pEdit->GetWindowTextW(sPort) //获取端口字符串 int dPort _ttoi(sPort) //获取端口整形 DWORD dwIP m_IP.GetAddress(dwIP) //获取ip sockaddr_in serAddr serAddr.sin_family AF_INET serAddr.sin_port htons(dPort) serAddr.sin_addr.S_un.S_addr htonl(dwIP) //创建连接 if (connect(sclient, (sockaddr*)&serAddr, sizeof(serAddr)) SOCKET_ERROR) { closesocket(sclient) AfxMessageBox(_T( connect error ! )) printf( connect error ! ) return }
Date : 2026-01-06 Size : 28.7mb User :
« 12 3 »
CodeBus is one of the largest source code repositories on the Internet!
Contact us :
1999-2046 CodeBus All Rights Reserved.