how to start server socket

prevragprevrag Member Posts: 5
We wrote server and client codes into codeunit but nothing happened. First we start server codeunit then client codeunit then we get the message

This message is for C/AL programmers:

The call to member GetStream failed. SocketBusAdapter.SocketBusAdapter.1 returned the following message:
Failed to connect to 127.0.0.1 on port 8079

Server code
IF ISCLEAR(CC2) THEN
    CREATE(CC2);
  IF ISCLEAR(SBA) THEN
    CREATE(SBA);

  CC2.AddBusAdapter(SBA, 0);

  SBA.OpenSocket(8079, '');

CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
InMsg:= InMessage;

  InS:= InMsg.GetStream();

  WHILE NOT (InS.EOS) DO
  BEGIN
    InS.READ(Txt);
    MESSAGE(Txt);
  END;

  InMsg.CommitMessage();
Client code
IF ISCLEAR(CC2) THEN
    CREATE(CC2);
  IF ISCLEAR(SBA) THEN
    CREATE(SBA);

  CC2.AddBusAdapter(SBA, 0);
  OutMsg:= CC2.CreateoutMessage('Sockets://localhost:8079');

  OutS:= OutMsg.GetStream();
  OutS.WRITE('First Text');
  OutS.WRITE('Second Text');
  OutS.WRITE('Third Text');

  OutMsg.Send(0);

Comments

Sign In or Register to comment.