tony@artecon.UUCP (04/30/87)
According to my manuals, the recvfrom call does not require the socket to be connected. However, I am getting an immediate return with the error: Socket not connected. Any ideas? This is what the code fragment looks like: #include <sys/types.h> #include <sys/socket.h> #define SOCKNAME "mysocket" main() /* server */ { int s,ns; /* socket descriptors */ static struct sockaddr name = {AF_UNIX,SOCKNAME}; static struct sockaddr nname; int nnamelen; int imsg; if ((s=socket(AF_UNIX,SOCK_STREAM,0)) < 0){ perror("cant open socket"); exit(-1); } if(bind(s,&name,sizeof(name)) < 0){ perror("cant bind to socket"); exit(-2); } nnamelen = sizeof(nname); if(recvfrom(s,&imsg,sizeof(imsg),0,&nname,&nnamelen) < 0){ perror("server recvfrom error"); exit(-5); } /* this is where it fails */ -- **************** Insert 'Standard' Disclaimer here: OOP ACK! ***************** * Tony Parkhurst -- {hplabs|sdcsvax|ncr-sd|hpfcla|ihnp4}!hp-sdd!artecon!adp * * -OR- hp-sdd!artecon!adp@nosc.ARPA * *******************************************************************************
lm@cottage.WISC.EDU (Larry McVoy) (05/01/87)
*) tony@artecon.artecon.UUCP (Anthony D. Parkhurst) writes:
*) According to my manuals, the recvfrom call does not require the
*) socket to be connected. However, I am getting an immediate
*) return with the error: Socket not connected. Any ideas?
*) ....
*) static struct sockaddr name = {AF_UNIX,SOCKNAME};
*) ....
*) if(recvfrom(s,&imsg,sizeof(imsg),0,&nname,&nnamelen) < 0){
Methinks that you must connect stream sockets. You can do what you're trying
to do here with UDP (datagram) sockets, but not stream sockets. Mail me
for examples of UDP & TCP socket code if you like.
Larry McVoy mcvoy@rsch.wisc.edu or uwvax!mcvoy
"What a wonderful world it is that has girls in it!"