如何知道局域网某台服务器开了8848的端口啊?(100分)

  • 主题发起人 主题发起人 scy_fjqz
  • 开始时间 开始时间
S

scy_fjqz

Unregistered / Unconfirmed
GUEST, unregistred user!
请教!
就像腾讯的企业qq程序,开启企业QQ客户端程序的时候,
就自动找到局域网开启企业QQ端服务程序的主机地址IP
 
试试telnet ipaddress 8848
 
我是说用程序去判断/
 
用clientsocket不幸么?
 
端口扫描程序的源码,你自己改改就可以了!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ScktComp;

type
TForm1 = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Label3: TLabel;
Bevel3: TBevel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Bevel4: TBevel;
Edit4: TEdit;
ListBox1: TListBox;
ClientSock1: TClientSocket;
procedure Button1Click(Sender: TObject);
procedure ClientSock1Connect(Sender: TObject; Socket: TCustomWinSocket);
procedure ClientSock1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
portno:integer;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
button1.enabled:=false;
edit1.enabled:=false;
edit2.enabled:=false;
edit3.enabled:=false;
edit4.enabled:=false;
button2.enabled:=true;
portno:=strtoint(edit2.text);
ClientSock1.address:=edit1.text;
ClientSock1.port:=portno;
ClientSock1.active:=true;
end;

procedure TForm1.ClientSock1Connect(Sender: TObject; Socket: TCustomWinSocket);
label son;
begin
listbox1.items.add('找到打开端口 : '+inttostr(portno));
ClientSock1.active:=false;
portno:=portno+1;
if portno > strtoint(edit3.text) then goto son else
ClientSock1.address:=edit1.text;
ClientSock1.port:=portno;
ClientSock1.active:=true;
son:

end;

procedure TForm1.ClientSock1Error(Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
label son;
begin
errorcode:=0;
edit4.text:='扫描端口 : '+inttostr(portno);
ClientSock1.active:=false;
portno:=portno+1;
if portno > strtoint(edit3.text) then goto son else
ClientSock1.address:=edit1.text;
ClientSock1.port:=portno;
ClientSock1.active:=true;
son:

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
portno:=strtoint(edit3.text);
button1.enabled:=true;
edit1.enabled:=true;
edit2.enabled:=true;
edit3.enabled:=true;
edit4.enabled:=true;
button2.enabled:=false;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
edit4.text:='';
listbox1.items.clear;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ClientSock1.active:=false;
end;



end.
 
我是说如何搜索整个局域网,找到开放某个端口的服务器!
 
不是使用 TClientSocket 而是使用 TServerSocket ,不然找不到。
 
可以换个角度考虑,
你的程序运行后进行UDP广播,如果有服务器存在,服务器进行回应,你就可以知道
整个局域网开放某个端口的所有服务器了!

仅代表个人观点!
 
控件名称:UDPADVERTISER.ZIP
作者:EricGrange
TUDPAdvertiser与TUDPAdUser是利用UDP通讯协议对网络进行封包广播(broadcasting)
的一组非可视构件(1.0版,附源码)
[blue]控件和例子[/blue]
http://www.neweasier.com/downloadvcl.html?id=2822

稍作改动即可
 
用Delphi6中的INDY控件组中的UDPClient和UDPServer也可以实现的!
 

Similar threads

后退
顶部