📄 readme.txt
字号:
TudpSocket (update) + Tnotify (look at included Tnotify.zip)
----------
file-id.diz
-----------
-----------
Author : Frank Dekervel
Belgium. kervel@hotmail.com.
http://kervel.home.ml.org
Version : 0.95 UPDATE
Copyright : 1998 , GPL BUT DO NOT USE IN COMMERCIAL PROGRAMS WITHOUT MY
PERMISSION.
DELPHI : compiles on D3 , needs winsock
unit (a converted .h file)
if u make update, plz contact me
TudpSocket is a component for using UDP in your applications. It is as easy
as Tsockets, but it has a different design because it is UDP. Therefore,
u can''t create connections or accept connections, u simply can bind the
UDPsocket to a specific port, and send UDP data to another machine/port.
U can also send broadcast messages, just send data to your subnet's broad-
cast address. Example : if your IP is 192.168.0.1 you can send a message to
192.168.0.255 , which is the broadcast address for subnet 192.168.0.0 . All
the computers with an IP beginning with 192.168.0. will receive your message.
So, you can make applications like winpopup, and the demo app is a simple
winpopup clone : run the demo on machines on the same subnet, fill in the
broadcast address, and send messages. Note : these messages won't be received
by winpopup, since winpopup use mailslots and not raw UDP.
I stole 1 procedure from the Tsockets component of Garry T Derosiers
(available freeware everywhere on the net)
The procedure is SocketErrorDesc , and gives a description of a winsock
error, so u won't see 'socket error 0x10084' anymore, but a nice description.
This is a simple way to send messages :
begin
Udpsocket1.Port := 1024; // if port 0 specified, winsock searches a free port
// number for you.
UdpSocket1.S_open; // binds UDPsocket to specified port.
// if you call S_open, and you did it before,
// S_close will be called automatically first, so
// you won't get an error.
Udpsocket1.Location:='192.168.0.1"; // the IP/hostname to send messages to
UdpSocket1.SendPort:=1024 // if 192.168.0.1 has port 1024 open, it ll
// receive your message. You'll never know if
// this is so, because you don't know if a send
// suxxeeds.
Udpsocket1.SendString('Hello computer 192.168.0.1 !!! how are you ??');
end;
The files :
-----------
-----------
UdpSocket.pas the component.
UdpSocket.dcr a nice icon for that component
(udpSocket.dcu) the compiled version of udpsocket.pas (not needed)
Udpnet.zip | a more complicated test application. also needs
Tnotify (notify.zip is included). This test
application has a form of chatting and e-mail
the EXE is included. take a look at it! This
program could be usefull for you.
Tnotify.zip | component needed by Udpnet.zip. Made by me also,
adds an icon in the systray and makes app invisible.
UdpTest.dof | udp tester sample application.
UdpTest.dpr |
UdpTest.res |
UdpTester2.pas the main unit of UdpTest
UdpTester2.dfm the main form of UdpTest
UdpTest.exe if u doubt, run this to check out (executable of UdpTest)
How To Install :
----------------
----------------
* Unzip everything into a new directory. There is no path info in the zip !
* Move UdpSocket.pas and UdpSocket.dcr in the lib/ directory, located in your
borland delphi (3) directory
* In the IDE, choose component|install component, and browse for the unit
udpsocket.pas
* install it into the package of your choice.
* The component will be installed into the 'TCP/IP' page. If you want to change
this, look for the line (one of the last lines [713] of the unit) :
RegisterComponents('TCP/IP', [TudpSocket]);
and change 'TCP/IP' in the page of your choice
* restart delphi. and if you use a version of delphi below 3.0 , restart
your PC. this ensures that the packages|vcl lib will be loaded correctly.
Description :
-------------
-------------
* Properties
------------
(RO = readonly, DT = designtime)
NAME RO DT DESC
Sockethandle X Returns the socket handle used by TUDPsocket.
Winhandle X Returns the windows handle used by " ".
CAUTION : do not use closehandle or closesocket
on one of those properties.
IsBound X True when the socket is bound and 'listening'
RemoteHostInfo X Gives u info about the host that is set up
for sending packets.
SendPort X The port of the machine u send packets to
Location X The location (hostname/ip) of the machine u send packets to
YOU DON'T HAVE TO REBIND WHEN YOU CHANGE THESE 2
port X The port the local machine is bound to. If you don't
need a fixed port, use 0.
reverseDNS X do a reverse DNS for each IP address given. ONLY
ENABLE THIS IF YOU REALLY NEED IT. IT IS SUPER-
SLOW ! (if you need it one time, e.g u're writing
a winnuke-protector using a Tsockets component,
and u want to know the hostname of ur aggressor,
set to true, call DNSlookup and set to false )
* Events
--------
Create constructor
Destroy destructor
DNSlookup looks up the given hostname, or if it is an IP
address, and reverseDNS is enabled, you'll get
a hostname.
S_open Opens a socket, and bind it to the port in the
PORT propterty.
S_close Closes the socket and releases the port.
OnError Occurs when winsock detects an error, or when a
winsock operation fails. it is recommended that
you specify one, because errors are verry current,
and it is important to take care of them.
OnReceive Occurs when data arrives at your bound socket.
In the handler, it is safe to call ReadBuf
or ReadString.
OnWriteReady Dunno if it works on UDP. occurs when buffers are
sent, and you can send new data. If you get a
'operation would block' error while sending, you'll
have to wait until this event occurs before trying again.
OnClose Occurs when the socket is closed. Useless.
* Methods
---------
SendBuff Sends a buffer to the machine in the location propterty,
and the port in the SendPort property
ReadBuff Fills a pchar (memory allocated or variabele/array
declared by you) with received data. The second
argument (len) lets you specify a maximum length,
but check the len variable again after reading,
now it contains the number of bytes received.
ReadBuff returns also information about the host
the packet was received from. If ReverseDNS is
specified, you also ll get a hostname.
SendString The same as sendbuff, but now with a pascal string.
ReadString readbuff
* Types
-------
TudpSocket The actual UDP socket
Terrorproc procedure type for error handlers
Teventproc same as TnotifyEvent
ThostAbout record that contains host information, such
as IP address or DNS name or both. can also
contain a port.
TSockMessage Winsock Asynchronous mode Windows Message type
MAIL IMPROVEMENTS TO kervel@hotmail.com
I AM NOT RESPONSIBLE FOR ANY DAMAGE CAUSED BY THIS COMPONENT
This component may only be used in non-commercial applications.
For commercial use, mail me.
Copyright Frank Dekervel 1998
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -