Communication Component Problem with Reply Message
drecksgekritzel
Member Posts: 37
Hello together,
I've written two codeunits to send messages between two different computer.
Therefore i use the socket communication how it is descriped in the devguide.chm on the installation cd.
Sending a message between two pcs works fine but the problem is the reply message.
The Reply is always empty if i try to get that back from a physically different pc.
If it is on the same one (client startet 2 times) then it works.
Can someone please look at that code and give me a little help to fix the problem?
(These are the two objects exported as text file)
Thanks in advance!
I've written two codeunits to send messages between two different computer.
Therefore i use the socket communication how it is descriped in the devguide.chm on the installation cd.
Sending a message between two pcs works fine but the problem is the reply message.
The Reply is always empty if i try to get that back from a physically different pc.
If it is on the same one (client startet 2 times) then it works.
Can someone please look at that code and give me a little help to fix the problem?
(These are the two objects exported as text file)
OBJECT Codeunit 50998 Send IP Port mit Reply
{
OBJECT-PROPERTIES
{
Datum=12.10.11;
Zeit=10:45:06;
Ge„ndert=Ja;
Versions Liste=SalAG;
}
PROPERTIES
{
OnRun=BEGIN
Send('localhost',8079);
END;
}
CODE
{
VAR
CC2@1000000000 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{01018FA5-E4B4-413C-A47C-AD34B0CC2647}:'Navision Communication Component version 2'.CommunicationComponent" WITHEVENTS;
SBA@1000000001 : Automation "{CF450AFF-91CE-4DF0-92DE-AFE4C28AAFC7} 1.0:{4CBE9566-34EA-429D-963A-911E270CBE4F}:'Navision Socket Bus Adapter'.SocketBusAdapter";
OutMsg@1000000002 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{6CB9762C-E61C-4F96-BA34-8B20D3A5B46E}:'Navision Communication Component version 2'.OutMessage";
ReplyMsg@1000000004 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{D184D0AC-61C9-4AC1-B537-0D28C277FEDE}:'Navision Communication Component version 2'.InMessage";
OutS@1000000003 : OutStream;
InStrm@1000000006 : InStream;
Reply@1000000005 : Boolean;
txt@1000000007 : Text[1000];
retval@1000000008 : Integer;
PROCEDURE Send@1000000000(Receiver@1000000000 : Text[30];Port@1000000001 : Integer);
BEGIN
IF ISCLEAR(CC2) THEN
CREATE(CC2);
IF ISCLEAR(SBA) THEN
CREATE(SBA);
CC2.AddBusAdapter(SBA, 0);
OutMsg:= CC2.CreateoutMessage('Sockets://' + Receiver + ':' + FORMAT(Port));
OutS:= OutMsg.GetStream();
OutS.WRITE('KOM0000000,4,1,2');
ReplyMsg := OutMsg.SendWaitForReply(10);
InStrm := ReplyMsg.GetStream;
WHILE NOT (InStrm.EOS) DO
BEGIN
InStrm.READ(txt);
MESSAGE(txt);
END;
MESSAGE(txt);
ReplyMsg.CommitMessage;
MESSAGE('fertig');
END;
EVENT CC2@1000000000::MessageReceived@1(VAR InMessage@1000000000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH");
BEGIN
END;
BEGIN
END.
}
}
OBJECT Codeunit 51000 Receive Msg IP Port mit Reply
{
OBJECT-PROPERTIES
{
Datum=11.10.11;
Zeit=15:32:46;
Ge„ndert=Ja;
Versions Liste=SalAG;
}
PROPERTIES
{
SingleInstance=Ja;
OnRun=BEGIN
Start(8079);
END;
}
CODE
{
VAR
CC2@1000000000 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{01018FA5-E4B4-413C-A47C-AD34B0CC2647}:'Navision Communication Component version 2'.CommunicationComponent" WITHEVENTS;
SBA@1000000001 : Automation "{CF450AFF-91CE-4DF0-92DE-AFE4C28AAFC7} 1.0:{4CBE9566-34EA-429D-963A-911E270CBE4F}:'Navision Socket Bus Adapter'.SocketBusAdapter";
InMsg@1000000002 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{D184D0AC-61C9-4AC1-B537-0D28C277FEDE}:'Navision Communication Component version 2'.InMessage";
InS@1000000003 : InStream;
txt@1000000004 : Text[1000];
Reply@1000000005 : Boolean;
ReplyMsg@1000000006 : Automation "{F9A57667-8AC5-45C5-9416-99D3955BCAC0} 1.0:{6CB9762C-E61C-4F96-BA34-8B20D3A5B46E}:'Navision Communication Component version 2'.OutMessage";
OutStrm@1000000007 : OutStream;
PROCEDURE Start@1000000000(Port@1000000000 : Integer);
BEGIN
IF ISCLEAR(CC2) THEN
CREATE(CC2);
IF ISCLEAR(SBA) THEN
CREATE(SBA);
CC2.AddBusAdapter(SBA, 0);
SBA.OpenSocket(Port, '');
END;
EVENT CC2@1000000000::MessageReceived@1(VAR InMessage@1000000000 : Automation ":{00020400-0000-0000-C000-000000000046}:''.IDISPATCH");
BEGIN
InMsg:= InMessage;
InS:= InMsg.GetStream();
WHILE NOT (InS.EOS) DO
BEGIN
InS.READ(txt);
MESSAGE(txt);
END;
Reply := InMsg.ExpectReply;
IF Reply THEN BEGIN
ReplyMsg := InMsg.CreateReply;
OutStrm := ReplyMsg.GetStream;
OutStrm.WRITETEXT('Reply message',13);
ReplyMsg.Send(0);
END;
InMsg.CommitMessage();
END;
BEGIN
END.
}
}
Thanks in advance!
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions