A From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  5-MAY-1993 12:05:53.49  To:	EVERHART CC:	2 Subj:	Need help with Multinet & TCP/IP Programming  D From: macika@emunix.emich.edu (Dominic Macika (Ass. Lab Supervisor))% X-Newsgroups: comp.lang.c,comp.os.vms 5 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 andA I'm exploring some tcp/ip programming.  I've hit a snag and can't A 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 E 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     O /******************************************************************************   *									      *O  *   MYSERVER.C - accept a datagram from the socket and write it to a file    *   *									      *P  ******************************************************************************/  6 #include "multinet_root:[multinet.include.sys]types.h"7 #include "multinet_root:[multinet.include.sys]socket.h" 7 #include "multinet_root:[multinet.include.netinet]in.h"  #include <stdio.h>2 #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 */ 2   char buf[BUFSIZ];			/* buffer for client data */   struct sockaddr_in	sin;      barf("log open\n");   1   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 */   3   n = recvfrom(s, buf, sizeof(buf), 0, &sin, &len);    if (n < 0) {     barf("recvform\n");    } 1   barf("Data received, heading for the file.\n");   Z   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);  }   P /*----------------------------------------------------------------------------*/" void barf( char *string_to_print ) {    FILE *errorlog;    if (N   (errorlog = fopen("emu$sysdevice:[lt521_434125.wrk]puncherrors.DAT", "a+"))        == NULL )    { exit (10); }   else   { %   fputs ( string_to_print, errorlog);    fclose (errorlog);   }  }     N 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.     L /***************************************************************************L  *                                                                         *L  *  MYCLIENT.C - send a data gram to the host                              *L  *                                                                         *M  ***************************************************************************/    #include<stdio.h>  #include<string.h> #include<netdb.h>  #include<sys/types.h>  #include<sys/socket.h> #include<netinet/in.h> #define BUFSIZE 256  #define PORT 4125 # #define HOSTNAME "laurel.emich.edu"  main() { "   int s;			/* socket descriptor */8   char buf[256];		/* buffer for client/server commun. */   struct servent *sp;    struct hostent *hp;    struct sockaddr_in sin;   1   if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {      perror ("socket");     exit(1);   }   /   if ((hp = gethostbyname(HOSTNAME)) == NULL) { 4     fprintf(stderr, "%s: host unknown.\n",HOSTNAME);     exit(1);   }      sin.sin_family = AF_INET;    sin.sin_port = htons(PORT); 1   bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);   "   strcpy (buf, "Venom was here.");  9   if (sendto(s,buf, BUFSIZE, 0, &sin, sizeof(sin)) < 0) {      perror("sendto");      exit(1);   }    else!     fprintf(stdout, "msg sent!");      close (s);
   exit(0); }    --  G Dominic Macika (with co-star, 8-Ball) Assistant Supervisor, Goddard Lab  macika@emunix.emich.edu         