From: SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 5-MAY-1993 12:05:53.49 To: EVERHART CC: Subj: Need help with Multinet & TCP/IP Programming From: macika@emunix.emich.edu (Dominic Macika (Ass. Lab Supervisor)) X-Newsgroups: comp.lang.c,comp.os.vms Subject: Need help with Multinet & TCP/IP Programming Date: 4 May 1993 20:01:41 GMT Organization: Eastern Michigan University Lines: 148 Message-Id: <1s6i35$c8c@zip.eecs.umich.edu> Nntp-Posting-Host: emunix.emich.edu Summary: help with tcp/ip Keywords: tcp/ip, recvfrom() To: Info-VAX@kl.sri.com X-Gateway-Source-Info: USENET Howdy. We recently had Multinet installed on our Vax 4000's and I'm exploring some tcp/ip programming. I've hit a snag and can't seem to find any answer for it. I'm simply trying to send a data gram from our unix system to our vax system. The server program I've written for the vax end hangs at the recvfrom() function. I assume it's not receiving the data I'm sending it. Any and all comments, suggestions and answers (heck, I'll even accept flames at this point, as long as they lead to something useful) will be greatly appreciated. Please resond via email and I will post a summary, etc. Source code: MYSERVER.C Compiled under VAX/VMS V5.5-1 Compiler: VAX C V3.2 MULTINET V1.0 /****************************************************************************** * * * MYSERVER.C - accept a datagram from the socket and write it to a file * * * ******************************************************************************/ #include "multinet_root:[multinet.include.sys]types.h" #include "multinet_root:[multinet.include.sys]socket.h" #include "multinet_root:[multinet.include.netinet]in.h" #include #include "multinet_root:[multinet.include]netdb.h" #define BUFSIZ 256 #define PORT 4125 void barf( char *); main() { int s, len, n; FILE *outfile; /* file to output data to */ char buf[BUFSIZ]; /* buffer for client data */ struct sockaddr_in sin; barf("log open\n"); if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { barf("error opening socket\n"); } barf("socket open\n"); len = sizeof(sin); barf("going into recvfrom\n"); /* this is the last message that makes it to my errorlog */ n = recvfrom(s, buf, sizeof(buf), 0, &sin, &len); if (n < 0) { barf("recvform\n"); } barf("Data received, heading for the file.\n"); if ((outfile = fopen("emu$sysdevice:[lt521_434125.wrk]SOCKET_TEST.DAT", "a+")) == NULL) barf("Error opening data file.\n" ); else { if (fputs(buf,outfile) == EOF) barf("Error writing to data file.\n"); fclose(outfile); } close(s); } /*----------------------------------------------------------------------------*/ void barf( char *string_to_print ) { FILE *errorlog; if ( (errorlog = fopen("emu$sysdevice:[lt521_434125.wrk]puncherrors.DAT", "a+")) == NULL ) { exit (10); } else { fputs ( string_to_print, errorlog); fclose (errorlog); } } Here's the source for the unix client program I'm using to send the data gram. MYCLIENT.C compiled under ULTRIX V4.2 with a RISC C compiler. /*************************************************************************** * * * MYCLIENT.C - send a data gram to the host * * * ***************************************************************************/ #include #include #include #include #include #include #define BUFSIZE 256 #define PORT 4125 #define HOSTNAME "laurel.emich.edu" main() { int s; /* socket descriptor */ char buf[256]; /* buffer for client/server commun. */ struct servent *sp; struct hostent *hp; struct sockaddr_in sin; if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror ("socket"); exit(1); } if ((hp = gethostbyname(HOSTNAME)) == NULL) { fprintf(stderr, "%s: host unknown.\n",HOSTNAME); exit(1); } sin.sin_family = AF_INET; sin.sin_port = htons(PORT); bcopy(hp->h_addr, &sin.sin_addr, hp->h_length); strcpy (buf, "Venom was here."); if (sendto(s,buf, BUFSIZE, 0, &sin, sizeof(sin)) < 0) { perror("sendto"); exit(1); } else fprintf(stdout, "msg sent!"); close (s); exit(0); } -- Dominic Macika (with co-star, 8-Ball) Assistant Supervisor, Goddard Lab macika@emunix.emich.edu