BookmarkSubscribeRSS Feed
jespersahner
Calcite | Level 5

Hi,

 

I am creating a client/server-connection using a socket.

 

The server just returns what it receives:

filename local socket ':5000' server reconn=0;
data _null_; infile local recfm=v; input; file local; response=_infile_; put response; run;

The first client looks like this:

filename remote socket 'localhost:5000';

data _null_;
  infile remote;

  request="Request1_from_client";
  file remote;
  put request;
  input;
  res=_infile_;
  file log;
  put res;

  request="Request2";
  file remote;
  put request;
  input;
  res=_infile_;
  file log;
  put res;

  stop;
run;

From the server the following is received:

Request1_from_client
Request2

 

The second client uses CALL routines instead of file/infile:

filename remote socket 'localhost:5000';

data _null_;
  fid=fopen('remote','W',2048,'V');

  request="Request1_from_client";
  rc=fput(fid,trim(request));
  rc=fwrite(fid);
  rc=fread(fid); 
  length res $2048;
  rc=fget(fid,res);
  file log;
  put res;

  request="Request2";
  rc=fput(fid,trim(request));
  rc=fwrite(fid);
  rc=fread(fid); 
  rc=fget(fid,res);
  file log;
  put res;

  stop;
run;

From the server the following is received:

Request1_from_client
Request1_from_clientRequest2

 

The problem is, that the File Data Buffer (FDB) isn't cleared, that is the second message is just added to the first message.

 

The question is how to clear the File Data Buffer (FDB)?

 

Note: One workaround is to close and reopen the connection but this is a bad solution because of time overhead, a socket-connection should stay open until work is done.

 

Regards,

Jesper

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 753 views
  • 0 likes
  • 1 in conversation