Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to use an open source MSN messenger(tmsnc oldest version) and it is out of support right now.
The problem is in socket part it is trying to connect hotmail.messenger.com (as host address) which is not supported any more, I searched about that and some guys were suggested to use
Quote:
messenger.hotmail.geo.msnmessenger.msn.com.akadns.net

instead but after it gives me the server in other parts such as send() it gives me connection reset by peer error or sometimes even cannot bind it.

Is that even possible to fix it? may by replacing other server or ...

What I have tried:

commented part is mine where i tried to simulate source part using getaddrinfo() and loop to find may a good result but in that way even it cannot bind.

int tcp_connect(char *server, int port)
 {
    /*
    struct addrinfo hints, *servinfo , *p;
    int sockfd;
    int rv;
    int yes = 1;
    
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;

    if ((rv = getaddrinfo("messenger.hotmail.geo.msnmessenger.msn.com.akadns.net", "4000", &hints, &servinfo)) != 0) {
            fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
            return 1;
    }

    // loop through all the results and bind to the first we can
    for(p = servinfo; p != NULL; p = p->ai_next) {
            if ((sockfd = socket(p->ai_family, p->ai_socktype,
                            p->ai_protocol)) == -1) {
                    perror("server: socket");
                    continue;
            }

            if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes,
                            sizeof(int)) == -1) {
                    perror("setsockopt");
                    exit(1);
            }

            if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
                    close(sockfd);
                    perror("server: bind");
                    continue;
            }
            
            if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
                close(sockfd);
                perror("client: connect");
                continue;
            }

            break;
    }

    freeaddrinfo(servinfo); // all done with this structure

    if (p == NULL)  {
            fprintf(stderr, "server: failed to bind\n");
            exit(1);
    }
    
    return sockfd;
    */    
        
        
        
    
    
        struct sockaddr_in localAddr, servAddr; // Used in connect and bind
        struct hostent *h; // Used for address resolving
        int rc; // Function return code
        int sd; // The socket descriptor

        //Resolve the address
        h = gethostbyname(server);
        if(h==NULL)
                return -1;

        servAddr.sin_family = h->h_addrtype;
        memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
        servAddr.sin_port = htons(port);

        //Initialize the socket
        sd = socket(AF_INET, SOCK_STREAM, 0);
        if(sd<0)
                return -1;

        localAddr.sin_family = AF_INET;
        localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
        localAddr.sin_port = htons(0);

        //Bind a local port for recieving data 
        rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
        if(rc<0)
                return -1;

        //Connect to the remote server
        rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
        if(rc<0)
                return -1;

        return sd;
}
Posted
Updated 27-Jun-18 21:41pm

1 solution

The problem is with the remote site and its availability. That is not a coding issue. Try https://www.messenger.com/[^].
 
Share this answer
 
Comments
Member 13606974 28-Jun-18 4:03am    
connection refused in connect() part.
Richard MacCutchan 28-Jun-18 4:37am    
Well as I said, that is a problem with the server not accepting your connection request. You cannot resolve this without help from the administrators of the remote site.
Member 13606974 28-Jun-18 4:59am    
but is there anyway to change these parts to telnet or i don't know by some way my own computer be host? (i don't know too much about socket and just recently road Beej's guide)
Richard MacCutchan 28-Jun-18 5:07am    
There is nothing to change. If the remote server will not accept your connection then there is nothing you can do. As I said, you must talk to the owners of the website for help.
Member 13606974 28-Jun-18 5:13am    
ok, thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900