Hi Joshua, Sorry for the delay in fixing this one. It was a simpler fix ;). I have now committed the fix into the svn (trunk + 1.2).
Please let me know if there is some other issue. Kapil On Tue, Sep 11, 2012 at 5:06 PM, Kapil Arya <[email protected]> wrote: > Hi Joshua, > > Thanks for reporting this. I think the fix is simpler and I will get back to > you as soon as I put the fix in the svn. > > Thanks, > Kapil > > On Tue, Sep 11, 2012 at 3:56 PM, Louie, Joshua D <[email protected]> > wrote: >> >> Hi, >> >> My code is launching a server with a port 0, so that it >> finds any free port. Then after that, it records the port number used and a >> client is launched that attaches to it. However, in restore, instead of >> recording the actual port it landed on and used, it appears to basically do >> the bind again with the port # of 0. As a result, my server is now on a >> different port, and my client cannot connect properly. Here’s some code that >> approximates the problem: >> >> >> >> /* Includes */ >> >> #include <assert.h> >> >> #include <stdio.h> >> >> #include <stdlib.h> >> >> #include <string.h> >> >> #include <signal.h> >> >> #include <unistd.h> >> >> #include <fcntl.h> >> >> #include <sys/types.h> >> >> #include <sys/socket.h> >> >> #include <sys/ipc.h> >> >> #include <netinet/in.h> >> >> #include <netdb.h> >> >> >> >> int main() { >> >> struct sockaddr_in server_addr; >> >> int i, socket_fd; >> >> unsigned int sockaddr_len = sizeof(struct sockaddr_in); >> >> >> >> /* Typical socket setup */ >> >> socket_fd = socket(AF_INET, SOCK_STREAM, 0); >> >> if (socket_fd < 0) { >> >> fprintf(stderr, "ERROR: Unable to open socket\n"); >> >> return 1; >> >> } >> >> >> >> /* Setup for finding any free port */ >> >> memset(&server_addr, 0, sizeof(server_addr)); >> >> server_addr.sin_family = AF_INET; >> >> server_addr.sin_port = htons(0); >> >> >> >> /* Bind and listen for a new connection, return the connection through >> >> * output parameter final_fd. >> >> */ >> >> server_addr.sin_addr.s_addr = INADDR_ANY; >> >> if (bind(socket_fd, (struct sockaddr *)&server_addr, >> >> sizeof(server_addr)) < 0) { >> >> fprintf(stderr, "ERROR: Unable to bind socket\n"); >> >> return 1; >> >> } >> >> >> >> for (i = 0; i < 100; i++) { >> >> /* Print the socket it is bound to. */ >> >> getsockname(socket_fd, (struct sockaddr *) &server_addr, >> &sockaddr_len); >> >> printf("Real socket is %u\n", >> ntohs(server_addr.sin_port)); >> >> sleep(3); >> >> } >> >> close(socket_fd); >> >> } /* END main */ >> >> >> >> When it gets to the part about printing the “Real socket is %u”, make a >> checkpoint. You’ll see that when you restart from that checkpoint you keep >> getting different numbers. >> >> >> >> Joshua Louie >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Dmtcp-forum mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/dmtcp-forum >> > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Dmtcp-forum mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dmtcp-forum
