当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 原文出处《Windows网络编程技术》第8章 完成端口模型 由于原书附的是C代码,我把其翻译成Delphi代码。
 

 

 ·delphi中的布尔类型     »显示摘要«
    摘要:delphi中定义了四种布尔类型:boolean,bytebool,wordbool和longbool。后面三种布尔类型是为了与其他语言兼容而引入的,一般情况下建议使用boolean类型。 这四种类型的布尔值占用内存的数量如下: boolean 1 byte bytebool 1 byte wordbool 2 bytes(1 word) longbool 4 bytes(2 words......
 ·delphi的调用约定     »显示摘要«
    摘要:calling conventions(调用约定) 在声明过程或函数时,你可以使用下面的指示字之一来指明调用约定:register、pascal、cdecl、stdcall以及safecall。比如,function myfunction(x, y: real): real; cdecl;... 调用约定决定了参数被传递给例程的顺序,它们也影响从堆栈中删除参数、传递参数时寄存器的使用,以及错误和异......


Winsock完成端口模型-Delphi代码

原文出处 «windows网络编程技术»第8章 完成端口模型

  【程序编程相关:在WIN2000/XP下添加自定义纸张的

由于原书附的是c代码,我把其翻译成delphi代码. 【推荐阅读:三层数据库与应用程序服务器的小型介绍(D

  【扩展信息:Delphi2005学习笔记4(续)——

其中winsock2.pas在delphi中不带,要另外下载http://jungla.dit.upm.es/~bti/files/winsock2.pas

 

program completionio;

{$apptype console}

uses

  sysutils,

  winsock2 in winsock2.pas,

  mains in mains.pas;

begin

    main();

end.

 

 

// module name: iocmplt.cpp

//

// description:

//

//    this sample illustrates how to develop a simple echo server winsock

//    application using the completeion port i/o model. this

//    sample is implemented as a console-style application and simply prints

//    messages when connections are established and removed from the server.

//    the application listens for tcp connections on port 5150 and accepts them

//    as they arrive. when this application receives data from a client, it

//    simply echos (this is why we call it an echo server) the data back in

//    its original form until the client closes the connection.

//

//  2005-2-5

//    cpp convert to delphi pas  by johnson

//   

unit mains;

interface

uses windows, winsock2, winsock, sysutils;

const

 port         = 5150;

 data_bufsize = 8192;

type

  lpvoid = pointer;

  lpper_io_operation_data = ^ per_io_operation_data ;

  per_io_operation_data = packed record

    overlapped: overlapped;

    databuf: twsabuf;

    buffer: array [0..data_bufsize] of char;

    bytessend: dword;

    bytesrecv: dword;

  end;


...   下一页
    摘要:其实autoinc字段很有价值,它提供了一个没有意义的唯一id,在很多场合都需要。(注意,通常的物料代码,身份证号,卡号等等现实属性都有意义,可能需要修改,不能用来做主键!最好采用无意义主键)但是delphi用ado(dbexpress我没有试过)连接关系数据库,在insert/apend post后,autoinc字段的值总为0(连access可以获得新值),这样在界面上不好看,而且不能刷新数据......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE