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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 762 views
  • 0 likes
  • 1 in conversation