开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: server programming in "C"


 

OK well here is the sample program from my system in file?$WCC:WATC.SOCK.SAMPLE... (Note: this will not compile because there are character set errors) ... but you can see some things missing from your sample program that seem to be in mine...
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /com ** Sample Waterloo C sockets program. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /com ** See the comment about DNS servers below. ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /com ** Tests functions: connect(), send(), recv(), muresolve(), ? ? ? ? ?
? ? /com ** ? musa2e(), muse2a() ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /inc watc ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? #include <socket.h> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? #include <stdio.h> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? #include <string.h> ? /* for memset(), etc. */ ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? #include <stdlib.h> ? /* for exit() */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? #include <errno.h> ? ?/* for access to errno */ ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* prototype for local function */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? static void crlf2nl(unsigned char *buf, int len); ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? int main(void) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? int i,n,rc,wlen; ? ? ?
? ? int sd; ?/* socket descriptor */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? unsigned long ipaddr; ?/* 32-bit IP address */ ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? unsigned char *sitename=""; ?/* site to connect to */ ? ?
? ? unsigned char *ipnum="132.206.120.4"; ?/* numeric IP addr to use ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? if sitename cannot be resolved by DNS */ ? ? ? ? ? ??
? ? int port=80; ? /* port number to connect to */ ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? struct sockaddr_in saddr; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? int numreads,totbytes; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? unsigned char *wrdata= ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ?"GET /msi/http/music.html HTTP/1.0\r\x25\r\x25"; ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? /* HTML request, to send to a web server. ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ?Note use of \r\x25 for CRLF. WatC Ebcdic: 0x0D 0x25. ? ? ? ? ? ?
? ? ? ? ? ? ?muse2a() and etoa() translate it to Ascii CR LF = 0x0D 0x0A. ? ?
? ? ? ? ? */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? unsigned char lastch,buf?400¨; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("\nWatC sockets sample program\n\n"); ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* Resolve the site name to an IP address */ ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /* Note: The muresolve functions uses a DNS server to lookup the ? ? ? ?
? ? ? ?IP address for the given site name (domain name).? This requires ? ??
? ? ? ?that you have 1 or more DNS server IP addresses defined in ? ? ? ? ??
? ? ? ?your $tcp:tcpip.config file, as NAMESERV records. ? ? ? ? ? ? ? ? ? ?
? ? ? ?Normally the DNS (Domain Name System) server IP addresses are ? ? ? ?
? ? ? ?provided by your ISP (Internet Service Provider). ? ? ? ? ? ? ? ? ? ?
? ? ? ?If you don't have any DNS servers, you can add the following ? ? ? ??
? ? ? ?record to file $tcp:ip.alias : ? 132.206.120.4 ? ? ??
? ? ? ?Or, in this source file, set: ?sitename="132.206.120.4" ? ? ? ? ? ? ?
? ? */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("Resolving site name %s\n",sitename); ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? rc=muresolve(sitename,&ipaddr); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(rc<0) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? { printf("** Error: unable to resolve site name %s\n" ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ?" ? ? muresolve() gave rc=%d\n",sitename,rc); ? ? ? ? ? ? ? ?
? ? ? ? printf("** Using a specific numeric IP address instead: %s\n", ? ? ?
? ? ? ? ? ? ? ?ipnum); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ipaddr=inet_addr(ipnum); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? sd=socket(AF_INET,SOCK_STREAM,0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("sd=%d from socket() create\n",sd); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(sd<0) { printf("** errno=%d\n",errno); exit(1); } ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /* Set up the socket address structure for connect() */ ? ? ? ? ? ? ? ? ?
? ? memset(&saddr,0,sizeof(saddr)); ?/* init. it to 0 */ ? ? ? ? ? ? ? ? ? ??
? ? saddr.sin_family=AF_INET; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? saddr.sin_port=htons((unsigned short)port); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? saddr.sin_addr.s_addr=ipaddr; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("Connecting to %s %s port %d\n",sitename, ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ?inet_ntoa(saddr.sin_addr),port); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? rc=connect(sd,(struct sockaddr *)&saddr,sizeof(saddr)); ? ? ? ? ? ? ? ? ?
? ? printf("rc=%d from connect()\n",rc); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(rc<0) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? { printf("** errno=%d\n",errno); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? if(errno==ECONNREFUSED) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? printf(" ? ?ECONNREFUSED - Connection refused\n"); ? ? ? ? ? ? ?
? ? ? ? if(errno==EHOSTUNREACH) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? printf(" ? ?EHOSTUNREACH - Host unreachable\n"); ? ? ? ? ? ? ? ?
? ? ? ? exit(1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* Write data to the socket */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? wlen=strlen(wrdata); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("# of bytes to be written: wlen=%d\ndata=|%s|\n",wlen,wrdata); ??
? ? muse2a(wrdata,wlen); ?/* convert from Ebcdic to Ascii! */ ? ? ? ? ? ? ??
? ? n=send(sd,wrdata,wlen,0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(n<0) printf("** rc=%d from send(). errno=%d\n",n,errno); ? ? ? ? ? ??
? ? else printf(" %d bytes written to socket\n",n); ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* Loop to read from the socket and display the data */ ? ? ? ? ? ? ? ??
? ? if(rc<0) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? { printf("** errno=%d\n",errno); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? if(errno==ECONNREFUSED) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? printf(" ? ?ECONNREFUSED - Connection refused\n"); ? ? ? ? ? ? ?
? ? ? ? if(errno==EHOSTUNREACH) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? printf(" ? ?EHOSTUNREACH - Host unreachable\n"); ? ? ? ? ? ? ? ?
? ? ? ? exit(1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /* Write data to the socket */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? wlen=strlen(wrdata); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? printf("# of bytes to be written: wlen=%d\ndata=|%s|\n",wlen,wrdata); ??
? ? muse2a(wrdata,wlen); ?/* convert from Ebcdic to Ascii! */ ? ? ? ? ? ? ??
? ? n=send(sd,wrdata,wlen,0); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(n<0) printf("** rc=%d from send(). errno=%d\n",n,errno); ? ? ? ? ? ??
? ? else printf(" %d bytes written to socket\n",n); ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* Loop to read from the socket and display the data */ ? ? ? ? ? ? ? ??
? ? rc=close(sd); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? printf("rc=%d from close() of socket\n",rc); ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? if(rc<0) { printf("** errno=%d\n",errno); exit(1); } ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? return 0; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? } ?/* end of main */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /* ---------------------------------------------------------------- */ ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? static void crlf2nl(unsigned char *buf, int len) ? ? ? ? ? ? ? ? ? ? ? ?
? ? /* Change all Ebcdic CRLF pairs to (blank,\n) */ ? ? ? ? ? ? ? ? ? ? ? ?
? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? int i,n1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? unsigned char ebc_crlf?2¨={0x0D,0x25}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? unsigned char blknl?2¨={' ','\n'}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? if(len<2) return; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? n1=len-1; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? for(i=0;i<n1;i++) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? { if(memcmp(buf+i,ebc_crlf,2)==0) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? { memcpy(buf+i,blknl,2); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? i++; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? } ?/* end of crlf2nl */ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? /inc $tcp:watc.sockets.obj ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? /inc $tcp:watc.muresolv.obj ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

Joe

On Mon, Jun 21, 2021 at 2:50 PM Tom Chandler <tchandler48@...> wrote:
/com ** Sample Waterloo C sockets program.
/com ** See the comment about DNS servers below.
/com ** Tests functions: connect(), send(), recv(), muresolve(),
/com ** ? musa2e(), muse2a()
/inc watc
#include <stdio.h>
#include <string.h> ? /* for memset(), etc. */
#include <stdlib.h> ? /* for exit() */
#include <errno.h> ? ?/* for access to errno */

/* prototype for local function */
static void crlf2nl(unsigned char *buf, int len);

int main(void)
{
int i,n,rc,wlen;
int sd; ? ?/* socket descriptor */
unsigned long ipaddr; ?/* 32-bit IP address */
unsigned char *sitename=""; ?/* site to connect to */
unsigned char *ipnum="132.206.120.4"; ?/* numeric IP addr to use
? ? ? ? ? ? ? ? ? ? if sitename cannot be resolved by DNS */
int port=80; ? ?/* port number to connect to */
struct sockaddr_in saddr;
int numreads,totbytes;
unsigned char *wrdata= \
? ? "GET /msi/http/music.html HTTP/1.0\r\x25\r\x25";
? ? ? ?/* HTML request, to send to a web server.
? ? ? ? ? Note use of \r\x25 for CRLF. WatC Ebcdic: 0x0D 0x25.
? ? ? ? ? muse2a() and etoa() translate it to Ascii CR LF = 0x0D 0x0A.
? ? ? ?*/
unsigned char lastch,buf[400];

printf("\nWatC sockets sample program\n\n");

/* Resolve the site name to an IP address */
/* Note: The muresolve functions uses a DNS server to lookup the
? ?IP address for the given site name (domain name).? This requires
? ?that you have 1 or more DNS server IP addresses defined in
? ?your $tcp:tcpip.config file, as NAMESERV records.
? ?Normally the DNS (Domain Name System) server IP addresses are
? ?provided by your ISP (Internet Service Provider).
? ?If you don't have any DNS servers, you can add the following
? ?record to file $tcp:ip.alias : ? 132.206.120.4
? ?Or, in this source file, set: ?sitename="132.206.120.4"
*/

rc = muresolve(sitename,&ipaddr);
if(rc < 0)
? {
? ? ? ? ? printf("** Error: unable to resolve site name %s\n"
? ? ? ? ? ?" ? ? muresolve() gave rc=%d\n",sitename,rc);
? ? ? printf("** Using a specific numeric IP address instead: %s\n",
? ? ? ? ? ?ipnum);
? ? ?ipaddr=inet_addr(ipnum);
? }

sd = socket(AF_INET,SOCK_STREAM,0);
printf("sd = %d from socket() create\n",sd);
if(sd < 0)
? ? ? ?{
? ? ? ? ? printf("** errno=%d\n",errno); exit(1);
? ? ? ?}

/* Set up the socket address structure for connect() */
memset(&saddr,0,sizeof(saddr)); ?/* init. it to 0 */
saddr.sin_family=AF_INET;
saddr.sin_port=htons((unsigned short)port);
saddr.sin_addr.s_addr=ipaddr;

printf("Connecting to %s %s port %d\n",sitename, \
? ? ? ?inet_ntoa(saddr.sin_addr),port);

rc = connect(sd,(struct sockaddr *)&saddr,sizeof(saddr));
printf("rc=%d from connect()\n",rc);

if(rc<0)
? { printf("** errno=%d\n",errno);
? ? if(errno==ECONNREFUSED)
? ? ? ? printf(" ? ?ECONNREFUSED - Connection refused\n");
? ? if(errno==EHOSTUNREACH)
? ? ? ? printf(" ? ?EHOSTUNREACH - Host unreachable\n");
? ? exit(1);
? }

/* Write data to the socket */
wlen=strlen(wrdata);
printf("# of bytes to be written: wlen=%d\ndata=|%s|\n",wlen,wrdata);
muse2a(wrdata,wlen); ?/* convert from Ebcdic to Ascii! */
n=send(sd,wrdata,wlen,0);
if(n<0) printf("** rc=%d from send(). errno=%d\n",n,errno);
else printf(" %d bytes written to socket\n",n);

/* Loop to read from the socket and display the data */
printf("Reading from socket...\n");
for(numreads=0,totbytes=0,lastch=0;;)
? { numreads++;
? ? n=recv(sd,buf,sizeof(buf),0);
? ? if(n<0) { printf("** rc=%d from recv(). errno=%d\n",n,errno);
? ? ? ? ? ? ? break; }
? ? if(n==0) break; ?/* end of data, server shutdown socket */
? ? totbytes+=n;
? ? musa2e(buf,n); ?/* convert from Ascii to Ebcdic! */
? ? crlf2nl(buf,n); ?/* then change all CRLF to (blank,\n) */
? ? ? ? /* Fix for case of CRLF split between buffers: */
? ? ? ? if(lastch==0x0D && buf[0]==0x25) buf[0]='\n';
? ? ? ? lastch=buf[n-1];
? ? ? ? if(lastch==0x0D) buf[n-1]=' ';
? ? for(i=0;i<n;i++) putc(buf[i],stdout);
? }
printf(" numreads=%d totbytes=%d\n",numreads,totbytes);

rc=close(sd);
printf("rc=%d from close() of socket\n",rc);
if(rc<0) { printf("** errno=%d\n",errno); exit(1); }

return 0;
} ? /* end of main */

/* ---------------------------------------------------------------- */

static void crlf2nl(unsigned char *buf, int len)
/* Change all Ebcdic CRLF pairs to (blank,\n) */
{
int i,n1;
unsigned char ebc_crlf[2]={0x0D,0x25};
unsigned char blknl[2]={' ','\n'};

if(len<2) return;
n1=len-1;
for(i=0;i<n1;i++)
? { if(memcmp(buf+i,ebc_crlf,2)==0)
? ? ? { memcpy(buf+i,blknl,2);
? ? ? ? i++;
? ? ? }
? }
} ?/* end of crlf2nl */



Virus-free.

On Mon, Jun 21, 2021 at 12:48 PM Joe Monk <joemonk64@...> wrote:
Ok do me a favor ... copy/paste the sample program in a reply to this email.

joe

On Mon, Jun 21, 2021 at 12:24 PM Tom Chandler <tchandler48@...> wrote:
tried the sample program int the dir $TCP and it will not work also.

Cheers
tom c


Virus-free.

On Mon, Jun 21, 2021 at 12:12 PM Joe Monk <joemonk64@...> wrote:
Ok first ... remember the manuals were written for Music 5.1. You are running Music/SP 6.2.

Look at the sample program. It should show everything you need.

Joe

On Mon, Jun 21, 2021 at 11:24 AM Tom Chandler <tchandler48@...> wrote:
I will try the change, but I found this, now to figure out how,what,when....


CARGCALL ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? This subroutine is intended for C programmers calling TCP/IP socket ? ? ? ?
? routines.? When called before the first socket routine, it guarantees that
? the arguments are passed in the manner C requires. ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
CALLING SEQUENCE: ?CALL CARGCALL(); ? ? ? ??
I think I am not linking to the correct MUSIC/SP library.
Got to learn more about compile time libraries.

The above was found in? the help menu, system subroutines.

Still working on it.
Cheers
Tom c
? ? ? ? ? ? ? ? ? ? ??

Virus-free.

On Mon, Jun 21, 2021 at 11:13 AM Peter Coghlan <groups@...> wrote:
>
> The change did not compile, something about a LVALUE needed.? BUT, I think
> you are on the right track.? See below from ar_pf3 manual:
>

In that case, you probably need something more complex than adding an &.
Maybe something like this:

int family = AF_INET;
int type = SOCK_STREAM;
int zero = 0;

sock = socket (&family, &type, &zero);

Regards,
Peter Coghlan.





Join [email protected] to automatically receive all group messages.