在局域网中向指定计算机发送消息(100分)

  • 主题发起人 主题发起人 xibaixin
  • 开始时间 开始时间
X

xibaixin

Unregistered / Unconfirmed
GUEST, unregistred user!
在一个局域网中向指定(知道MAC网卡地址)计算机发送消息。最好是在对方计算机不安客户端软件。发送的计算机甲在局域网中,和接收的计算机乙是同等关系,就是甲也不是服务器。当然软件要安装在甲计算机上。计算机的操作系统是WIN XP
 
用DOS命令
NET SEND
{name | * | /DOMAIN[:name] | /USERS} message
试试
 
楼上方案不错但对方必须启动了Messenger服务。
 
在同在一城市里,怎么和指定的人通电话(已经给那个人拥有的手机卡的手机号码了)。最好他不需要有手机。我们的关系是平等的我不用打电话给他,他也不用打电话给我。当然我是有手机的。我们用的手机卡都是移动的。
楼上的楼上方案不错,但是要给他买手机,并且还要给他打电话。
哈哈。。。。。。
 
要实现消息通讯,不管是安装软件还是启用 Messenger 服务都得有个程序常驻内存来负责消息的发送与接收工作。
如果你想要稳定的实现这个功能,安装软件当然是首选。你也不希望自己发送了个消息给对方后还要找对方确认一下消息是否已经收到了。相信你也不希望在自己工作的时候忽然弹出一个 Messager 服务的消息的对话框来搅乱你的工作,特别是你正在跟 PLMM 聊天的时候。
 
启用 Messenger 服务,你们说的是类似QQ的MSN,还是后台服务Messenger。
我试了试,不行
 
用软件也行,有代码最好了。先谢。
 
net send 是內部的消息機制,有一項服務要打開才OK的。
 
net send 不太好用!不稳定!
 
大家说说
 
局域网聊天,楼主说似简单,其实涉及到很多问题的。
以下是 Indy 官方发布,用 UDP 实现通讯的 Demo,楼主参考一下吧。
1.客户端
{-----------------------------------------------------------------------------
Demo Name: UDP Client
Author: <unknown - please contact me to take credit! - Allen O'Neill>
Copyright: Indy Pit Crew
Purpose:
History:
Date: 27/10/2002 01:00:36
Checked with Indy version: 9.0 - Allen O'Neill - Springboard Technologies Ltd - http://www.springboardtechnologies.com
-----------------------------------------------------------------------------
Notes:
Simple UDP client demo
}

unit UDPClientMain;
interface
uses
Windows, Messages, Graphics, Controls, Forms, Dialogs, IdWinsock2, stdctrls,
SysUtils, Classes, IdBaseComponent, IdAntiFreezeBase, IdAntiFreeze,
IdComponent, IdUDPBase, IdUDPClient, IdStack;
type
TUDPMainForm = class(TForm)
SourceGroupBox: TGroupBox;
HostNameLabel: TLabel;
HostAddressLabel: TLabel;
HostName: TLabel;
HostAddress: TLabel;
UDPAntiFreeze: TIdAntiFreeze;
PortLabel: TLabel;
Port: TLabel;
DestinationLabel: TLabel;
DestinationAddress: TLabel;
BufferSizeLabel: TLabel;
BufferSize: TLabel;
UDPMemo: TMemo;
SendButton: TButton;
UDPClient: TIdUDPClient;
procedure FormCreate(Sender: TObject);
procedure SendButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
UDPMainForm: TUDPMainForm;
implementation
const
HOSTNAMELENGTH = 80;
RECIEVETIMEOUT = 5000;
// milliseconds
{$R *.DFM}
procedure TUDPMainForm.FormCreate(Sender: TObject);
begin
Randomize;
// remove if you want reproducible results.
HostName.Caption := UDPClient.LocalName;
HostAddress.Caption := GStack.LocalAddress;
Port.Caption := IntToStr(UDPClient.Port);
DestinationAddress.Caption := UDPClient.Host;
BufferSize.Caption := IntToStr(UDPClient.BufferSize);
UDPClient.ReceiveTimeout := RECIEVETIMEOUT;
end;

procedure TUDPMainForm.SendButtonClick(Sender: TObject);
var
MessageID: Integer;
ThisMessage: String;
ReceivedString: String;
begin
MessageID := Random(MAXINT);
ThisMessage := 'Message: ' + IntToStr(MessageID);
UDPMemo.Lines.Add('Sending ' + ThisMessage);
UDPClient.Send(ThisMessage);
ReceivedString := UDPClient.ReceiveString();
if ReceivedString = '' then
UDPMemo.Lines.Add('No response received from the server after ' + IntToStr(UDPClient.ReceiveTimeout) + ' millseconds.')
else
UDPMemo.Lines.Add('Received: ' + ReceivedString)
end;

end.

2.服务器端
{-----------------------------------------------------------------------------
Demo Name: UDP Server
Author: <unknown - please contact me to take credit! - Allen O'Neill>
Copyright: Indy Pit Crew
Purpose:
History:
Date: 27/10/2002 01:00:36
Checked with Indy version: 9.0 - Allen O'Neill - Springboard Technologies Ltd - http://www.springboardtechnologies.com
-----------------------------------------------------------------------------
Notes:
Simple UDP server demo
}
unit UDPServerMain;
interface
uses
Windows, Messages, Graphics, Controls, Forms, Dialogs, IdWinsock2, stdctrls,
SysUtils, Classes, IdBaseComponent, IdAntiFreezeBase, IdAntiFreeze,
IdComponent, IdUDPBase, IdUDPClient, IdStack, IdUDPServer, IdSocketHandle;

type
TUDPMainForm = class(TForm)
SourceGroupBox: TGroupBox;
HostNameLabel: TLabel;
HostAddressLabel: TLabel;
HostName: TLabel;
HostAddress: TLabel;
UDPServer: TIdUDPServer;
UDPAntiFreeze: TIdAntiFreeze;
PortLabel: TLabel;
Port: TLabel;
BufferSizeLabel: TLabel;
BufferSize: TLabel;
UDPMemo: TMemo;
procedure FormCreate(Sender: TObject);
procedure UDPServerUDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;

var
UDPMainForm: TUDPMainForm;
implementation
const
HOSTNAMELENGTH = 80;
{$R *.DFM}
procedure TUDPMainForm.FormCreate(Sender: TObject);
begin
HostName.Caption := UDPServer.LocalName;
HostAddress.Caption := GStack.LocalAddress;
Port.Caption := IntToStr(UDPServer.DefaultPort);
BufferSize.Caption := IntToStr(UDPServer.BufferSize);
UDPServer.Active := True;
end;

procedure TUDPMainForm.UDPServerUDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
s: String;
begin
DataStringStream := TStringStream.Create('');
try
DataStringStream.CopyFrom(AData, AData.Size);
UDPMemo.Lines.Add('Received "' + DataStringStream.DataString + '" from ' + ABinding.PeerIP + ' on port ' + IntToStr(ABinding.PeerPort));
s := 'Replied from ' + UDPServer.LocalName + ' to "' + DataStringStream.DataString + '"';
ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, s[1], Length(s));
finally
DataStringStream.Free;
end;
end;

end.
 
谢谢,我再看看
 
iyinwei的就可以..你仿照写个看看...
 
多人接受答案了。
 
后退
顶部