memo-delphi

所属分类:数据库编程
开发工具:Delphi
文件大小:128KB
下载次数:0
上传日期:2018-10-29 01:09:15
上 传 者Colbert
说明:  基于ipx协议的delphi控件演示程序,可以学习使用,不错
(Ipx protocol based on the delphi control demo program, you can learn to use, good)

文件列表:
x0qEIPXUNIT.DCR (460, 2017-04-11)
ZIPXUNIT.DCU (20917, 2017-04-11)
7NIPXUNIT.PAS (33350, 2017-04-11)
y3HIPXTEST.ZIP (113821, 2017-04-11)

IPXUNIT ======== The SPX(Sequenced Packet Exchange)/IPX(Internetwork Packet Exchange) network protocol, popularized by Novell Netware in many platform, MS-DOS, Windows, Windows 95/NT, OS/2, UNIX...etc. Version 1.0 I implement the IPX network protocol component (VCL) for Delphi 2.0. It provide a easy interface for user to transmit and receive data. It call Winsock 1.1 API to make this protocol. FILE CONTENT ============ IPXUNIT.PAS : component source code IPXUNIT.DCU : component object code IPXUNIT.DCR : component resource file README.TXT : this file IPXTEST.ZIP : a demo program INSTALLATION ============ Enter Delphi, select the menu [Component]/[Install], click the [Add] button then the [Browse] button. Select the IPXUNIT.DCU or IPXUNIT.PAS in where it located and click [OK] button. The component will appear in the [System] folder in the component palette. If you want to see the demo, you must do following separatley in two computers. First, to install demo program, use winzip or pkunzip to decompress IPXTEST.ZIP to a directory. Second, install and startup the IPX driver in the computer and then execute the demo program 'IPXTEST.EXE', Note! each computer do the same thing to here. Following, all you must to do is to press [Start] button in the application window in each computer, then press [Send] button in one. Some message will be sent to the other end and appear in memo field. Use other functions, see following content in this document, you will understand them. USAGE ===== After installing the component, drag it from the component palette and drop to the form, then do following: 1) Attach an event handler to 'OnReceiveData' for incoming data. 2) Call 'Open' to enable and start the protocol. 3) Use the 'Send' method to write data to network. 4) Call 'Close' to close the protocol. PROPERTY ======== AllowSendBroadcast : Boolean; (R/W, run-time/design-time) The member is to decide if we can send broadcast packet. A broadcast packet is that its remote-node-number is FF.FF.FF.FF.FF.FF and can be sent to all stations in that network. If this member is FALSE and the remote- node-number is FF.FF.FF.FF.FF.FF, will raise a error when calling 'Send' method to send a packet. When you set it and a system error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer setsockopt() Linger : Boolean; (R/W, run-time/design-time) LingerTimeout : u_short; (R/W, run-time/design-time) LINGER controls the action taken when unsent data is queued on a socket and a closesocket is performed. Linger LingerTimeout Type of close Wait for Close method? -------- ------------- ------------------ --------------------- False Don't care Wait in background No (default) until gueued data is sent True Zero ignore queued data No True Nonzero Wait for 'timeout' Yes seconds ot process queued data I don't implement the function and it do nothing now, I will implement it in future. LocalNetworkNumber : String; (Read only, run-time only) LocalNodeNumber : String; (Read only, run-time only) LocalSocketNumber : u_short; (R/W, run-time/design-time) These members are our network address, and other hosts can transmit data to me according them. We must set 'LocalSocketNumber' before calling 'Open' method. It indicate the channel between this component and the IPX driver. 'LocalNetworkNumber' and 'LocalNodeNumber' is set by the IPX driver. The driver fill them after your calling 'Open' successfully. 'LocalNetworkNumber' which is in XX.XX.XX.XX format (every XX is a hex-number) is our network number and is get from novell server or from that have set in: [Control panel]/ [Network] applet/ [IPX/SPX compatible network protocol] item/ [Property] button/ [Advance] folder/ value of [Network number] item 'LocalNodeNumber' which is in XX.XX.XX.XX.XX.XX format (every XX is a hex-number) is our node number, the 6-byte code set in our network adapter(card). After socket in opened, you change 'LocalSocketNumber' make NO any effect. Example: IPX1.LocalSocketNumber := 3; // set socket number to 3 IPX1.Open; // Open the protocol and success Label1.Caption := IPX1.LocalNodeNumber; // Show 00.86.21.22.BF.3A in Label1 PacketTypeFilter : u_short; (R/W, run-time/design-time) PacketTypeFiltered : Boolean; (R/W, run-time/design-time) Packet-type, a field live on offset 05h in IPX header, indicate what type of this packet. they usually have following value: 00h unknown packet type 01h routing information packet 02h echo packet 03h error packet 04h packet exchange packet (always use this one) 05h SPX packet 11h NetWare Core Protocol 14h Propagated Packet(for NetWare), NetBIOS name packet 15h-1Eh experimental protocols This two members is used to filter the incoming packet. If 'PacketTypeFiltered' is TRUE, packets with a packet type that does not match the 'PacketTypeFilter' are discarded. When you set one of them and a system error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer setsockopt() ReceiveHeader : Boolean; (R/W, run-time/design-time) Every packet include a header in front of data. If this member is TRUE, the data that transmit to your event handler 'OnReceiveData' will include the header information. When you set it and a system error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer setsockopt() (This protocol is defined in WSIPX.H. But I try to enable it and no see any header information add-on incoming data ????) RemoteNetworkNumber : String; (R/W, run-time/design-time) RemoteNodeNumber : String; (R/W, run-time/design-time) RemoteSocketNumber : u_short; (R/W, run-time/design-time) These members are the destination network address that our output packet will be sent to. Before we send out a packet, we must have set them with correct format and value. 'RemoteNetworkNumber' which must in XX.XX.XX.XX format (every XX is a hex-number) is the network number which the other station connect in. 'RemoteNodeNumber' which must in XX.XX.XX.XX.XX.XX format (every XX is a hex-number) is the node number which is the 6-byte code set in the network adapter inside the other station. 'RemoteSocketNumber' is the socket number that the application used to create its socket in the other station. Or say the 'LocalSocketNumber' in that application in the other station. If the remote station and our station are connected in the same network bus, the 'RemoteNetworkNumber' will be ignored. If 'AllowSendBroadcast' is TRUE and 'RemoteNodeNumber' is FF.FF.FF.FF.FF.FF, we send the broadcast packet to every station in that network. Examples: IPX1.RemoteNetworkNumber := // Set remote network number to '0.0.0.1'; // 00.00.00.01 IPX1.RemoteNodeNumber := // Set remote node number to '0.80.E.13.22.4B'; // 00.80.0E.13.22.4B IPX1.RemoteSocketNumber := 3; // Set remote socket number to 3 IPX1.Open; // Open the protocol IPX1.Send( buffer, 5 ); // Send 5 byte data to the application // address in // 0.0.0.1:00.80.0E.13.22.4B:3 IPX1.RemoteNodeNumber := // Set remote node number to '00.81.B1.14.1D.44'; // 00.81.B1.14.1D.44 IPX1.Send( 'abc', 3 ); // Send 'abc' to application address in // 0.0.0.1:00.81.B1.14.1D.44:3 IPX1.RemoteNodeNumber := 'FF.FF.FF.FF.FF.FF'; // No define the specific node number // Will send broadcast packet IPX1.Send( buffer, 5 ); // Send 5 byte data to the // application(s) address in // 0.0.0.1:(don't care):3 IPX1.RemoteNetworkNumber := // Set remote network number to '0.0.0.8'; // 00.00.00.08 IPX1.RemoteSocketNumber := $12; // Set remote socket number to 0012h IPX1.Send( buffer, 5 ); // Send 5 byte data to the application // address in // 0.0.0.8:(don't care):0012 IPX1.RemoteNetworkNumber := // Set remote network number to '0.0.123.8'; // 00.00.23.08 ^^^ illegal SendPacketType : u_short; (R/W, run-time/design-time) Packet-type, a field live on offset 05h in IPX header, indicate what type of this packet. they usually have following value: 00h unknown packet type 01h routing information packet 02h echo packet 03h error packet 04h packet exchange packet (always use this one) 05h SPX packet 11h NetWare Core Protocol 14h Propagated Packet(for NetWare), NetBIOS name packet 15h-1Eh experimental protocols When you send a packet, the Packet-type field in the IPX header in front of this packet is set to this value. When you set it and a system error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer setsockopt() MaxSendDataSize : Integer; (Read only, run-time only) Read this to known the maximum data size that can be sent. This value will be the maximun value in the second parameter for 'Send' method. You can read this value after calling 'Open' successfully. (I read it under Win95 is 1467, but I know that 546 is the maximun permit for NetWare IPX driver). (NetWare say that maximun IPX packet size is 576 bytes, which include IPX Header(30 bytes), so the maximun size of data part in one packet is 546 bytes). Handle : THandle; (Read only, run-time only) This value is get from socket(..) call at 'Open' method. It is very like the handle used for files and windows. You can use this member to call other Winsock API. If the socket is in use (open), its value is >= 0. If the socket is not in use (close). its value is -1 METHOD ====== procedure Open; Create a socket and active the IPX protocol. After calling this method successfully, you can communication with others. Parameters: none If error happened, new socket won't be created and system raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer socket(), setsockopt(), bind(), getsockname(), WSAAsyncSelect() procedure Close; Close the socket to stop communication. About the behavier of this call, please refer 'Linger'. Parameters: none If error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer closesocket() procedure Send( Buffer : Pointer ; BufferLength : Integer ); Send data contain in Buffer out. You must call this method after calling 'Open' successfully. Parameters: Buffer : the buffer contain the data which will be sent BufferLength : The data size in Buffer If error happened, will raise ESocketError exception and ESocketError.Message : the error message string ESocketError.Error : the error code get from WSAGetLastError please refer sendto() EVENT ===== OnReceiveData : procedure ( Sender:TObject; Buffer:PChar; BufferLength:Integer; SockAddr:TSockAddrIPX; SockAddrLen:Integer ) of object; Every time a packet is correctly received, this handler is called. Parameters: Buffer : contain the received data BufferLength : the size of the received data SockAddr : the source address the packet come from TSockAddrIPX = packed record sa_family : short; // should be AF_IPX or AF_NS sa_netnum : array [0..3] of Byte; // the network number sa_nodenum : array [0..5] of Byte; // the node number sa_socket : u_short; // the socket number end; SockAddrLen : the size of SockAddr. Should be 14 OnSendDataEmpty : procedure ( Sender:TObject ) of object; When data in the send buffer is empty, this handler is called. Having successfully posted to this handler, no further post to this handler will be happened until the application call the 'Send' method which implicitly re-enables notification of the network event. OnErrorHappened : procedure ( Sender:TObject; EventWord:Integer; ErrorCode:Integer; ErrorMsg:String ) of object; Some operations like 'receive' and 'send' are done in background. When they have error happened, this handler is called. Parameters: EventWord : the type of error. May be FD_READ or FD_WRITE ErrorCode : the error code get from WSAGetSelectError(msg.LParam) ErrorMsg : the error message string LEGALITIES ========== This component is totally free(copyleft), you can do anything in any purpose EXCEPT SELL IT ALONE. If you improve it or fix bugs, hope you send me a copy. Hope that everyone can give me more suggestion about this component. Author : ¤p¤u§@ Small-Pig Team From : Taiwan R.O.C. Email : spig@vlsi.ice.cycu.edu.tw Date : 1997/4/28

近期下载者

相关文件


收藏者