uses WinSock;然后大至按以下步骤操作,建议买本网络通信的书看一下var WData: TWSAData;
begin
WSAStartup(MakeWord(1,1), WData);
socket(.......创建套接字
bind(.......帮定端口
listen(.....开始监听
repeat
accept(.....开始建立链接
//..........
until true;
end;
以下是WinSock单元中从系统的wsock32.dll中输出的WinSocket操作函数
function accept; external winsocket name 'accept';
function bind; external winsocket name 'bind';
function closesocket; external winsocket name 'closesocket';
function connect; external winsocket name 'connect';
function getpeername; external winsocket name 'getpeername';
function getsockname; external winsocket name 'getsockname';
function getsockopt; external winsocket name 'getsockopt';
function htonl; external winsocket name 'htonl';
function htons; external winsocket name 'htons';
function inet_addr; external winsocket name 'inet_addr';
function inet_ntoa; external winsocket name 'inet_ntoa';
function ioctlsocket; external winsocket name 'ioctlsocket';
function listen; external winsocket name 'listen';
function ntohl; external winsocket name 'ntohl';
function ntohs; external winsocket name 'ntohs';
function recv; external winsocket name 'recv';
function recvfrom; external winsocket name 'recvfrom';
function select; external winsocket name 'select';
function send; external winsocket name 'send';
function sendto; external winsocket name 'sendto';
function setsockopt; external winsocket name 'setsockopt';
function shutdown; external winsocket name 'shutdown';
function socket; external winsocket name 'socket';function gethostbyaddr; external winsocket name 'gethostbyaddr';
function gethostbyname; external winsocket name 'gethostbyname';
function getprotobyname; external winsocket name 'getprotobyname';
function getprotobynumber; external winsocket name 'getprotobynumber';
function getservbyname; external winsocket name 'getservbyname';
function getservbyport; external winsocket name 'getservbyport';
function gethostname; external winsocket name 'gethostname';function WSAAsyncSelect; external winsocket name 'WSAAsyncSelect';
function WSARecvEx; external winsocket name 'WSARecvEx';
function WSAAsyncGetHostByAddr; external winsocket name 'WSAAsyncGetHostByAddr';
function WSAAsyncGetHostByName; external winsocket name 'WSAAsyncGetHostByName';
function WSAAsyncGetProtoByNumber; external winsocket name 'WSAAsyncGetProtoByNumber';
function WSAAsyncGetProtoByName; external winsocket name 'WSAAsyncGetProtoByName';
function WSAAsyncGetServByPort; external winsocket name 'WSAAsyncGetServByPort';
function WSAAsyncGetServByName; external winsocket name 'WSAAsyncGetServByName';
function WSACancelAsyncRequest; external winsocket name 'WSACancelAsyncRequest';
function WSASetBlockingHook; external winsocket name 'WSASetBlockingHook';
function WSAUnhookBlockingHook; external winsocket name 'WSAUnhookBlockingHook';
function WSAGetLastError; external winsocket name 'WSAGetLastError';
procedure WSASetLastError; external winsocket name 'WSASetLastError';
function WSACancelBlockingCall; external winsocket name 'WSACancelBlockingCall';
function WSAIsBlocking; external winsocket name 'WSAIsBlocking';
function WSAStartup; external winsocket name 'WSAStartup';
function WSACleanup; external winsocket name 'WSACleanup';
function __WSAFDIsSet; external winsocket name '__WSAFDIsSet';function TransmitFile; external winsocket name 'TransmitFile';
function AcceptEx; external winsocket name 'AcceptEx';
procedure GetAcceptExSockaddrs; external winsocket name 'GetAcceptExSockaddrs';
begin
WSAStartup(MakeWord(1,1), WData);
socket(.......创建套接字
bind(.......帮定端口
listen(.....开始监听
repeat
accept(.....开始建立链接
//..........
until true;
end;
以下是WinSock单元中从系统的wsock32.dll中输出的WinSocket操作函数
function accept; external winsocket name 'accept';
function bind; external winsocket name 'bind';
function closesocket; external winsocket name 'closesocket';
function connect; external winsocket name 'connect';
function getpeername; external winsocket name 'getpeername';
function getsockname; external winsocket name 'getsockname';
function getsockopt; external winsocket name 'getsockopt';
function htonl; external winsocket name 'htonl';
function htons; external winsocket name 'htons';
function inet_addr; external winsocket name 'inet_addr';
function inet_ntoa; external winsocket name 'inet_ntoa';
function ioctlsocket; external winsocket name 'ioctlsocket';
function listen; external winsocket name 'listen';
function ntohl; external winsocket name 'ntohl';
function ntohs; external winsocket name 'ntohs';
function recv; external winsocket name 'recv';
function recvfrom; external winsocket name 'recvfrom';
function select; external winsocket name 'select';
function send; external winsocket name 'send';
function sendto; external winsocket name 'sendto';
function setsockopt; external winsocket name 'setsockopt';
function shutdown; external winsocket name 'shutdown';
function socket; external winsocket name 'socket';function gethostbyaddr; external winsocket name 'gethostbyaddr';
function gethostbyname; external winsocket name 'gethostbyname';
function getprotobyname; external winsocket name 'getprotobyname';
function getprotobynumber; external winsocket name 'getprotobynumber';
function getservbyname; external winsocket name 'getservbyname';
function getservbyport; external winsocket name 'getservbyport';
function gethostname; external winsocket name 'gethostname';function WSAAsyncSelect; external winsocket name 'WSAAsyncSelect';
function WSARecvEx; external winsocket name 'WSARecvEx';
function WSAAsyncGetHostByAddr; external winsocket name 'WSAAsyncGetHostByAddr';
function WSAAsyncGetHostByName; external winsocket name 'WSAAsyncGetHostByName';
function WSAAsyncGetProtoByNumber; external winsocket name 'WSAAsyncGetProtoByNumber';
function WSAAsyncGetProtoByName; external winsocket name 'WSAAsyncGetProtoByName';
function WSAAsyncGetServByPort; external winsocket name 'WSAAsyncGetServByPort';
function WSAAsyncGetServByName; external winsocket name 'WSAAsyncGetServByName';
function WSACancelAsyncRequest; external winsocket name 'WSACancelAsyncRequest';
function WSASetBlockingHook; external winsocket name 'WSASetBlockingHook';
function WSAUnhookBlockingHook; external winsocket name 'WSAUnhookBlockingHook';
function WSAGetLastError; external winsocket name 'WSAGetLastError';
procedure WSASetLastError; external winsocket name 'WSASetLastError';
function WSACancelBlockingCall; external winsocket name 'WSACancelBlockingCall';
function WSAIsBlocking; external winsocket name 'WSAIsBlocking';
function WSAStartup; external winsocket name 'WSAStartup';
function WSACleanup; external winsocket name 'WSACleanup';
function __WSAFDIsSet; external winsocket name '__WSAFDIsSet';function TransmitFile; external winsocket name 'TransmitFile';
function AcceptEx; external winsocket name 'AcceptEx';
procedure GetAcceptExSockaddrs; external winsocket name 'GetAcceptExSockaddrs';
解决方案 »
- tquery部件的sql语句实现多表查询.数据库别名问题
- ■■■ 很有挑战性的题目 ■■■
- 高分求助,如何知道系统是否被锁定(Ctrl+Alt+Delete)
- 树结点没有子节点,如何显示前面的+号,让它看起来好像还有子结点呢
- 跪求赐教
- 请教DSPACK播放流的问题
- 我是Delphi的新手,和一位网友的情况一样,我在“黑白软件”下载的Delphi 6和7,我希望安装完程序窗体的风格像金山词霸一样,可是怎么还
- 我在我的子从窗体的子窗体内使用了CreateThread的线程,使用后关闭窗体就会出现"System Error. Code: 1400. 无效的窗口句柄"的错误!各位高
- 请问用什么控件向哪个端口发送数据包可以让机器重启动?
- 如何获取当前dbgrid中某一行的记录,并复制到另外一个窗口的几个dbedit上???
- 菜鸟问题:系统关闭时。。。
- 程序必须解决的问题,挑战winxp.win2000
[email protected]